0% found this document useful (0 votes)
50 views23 pages

Chapter 3 - File Systems

This document discusses Linux file systems and text editing. It describes the Linux directory structure, including directories, pathnames and file types. It covers commands for changing directories, listing files, and viewing file contents. It also discusses wildcards, regular expressions, and text editors like vi that are used for viewing and editing files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views23 pages

Chapter 3 - File Systems

This document discusses Linux file systems and text editing. It describes the Linux directory structure, including directories, pathnames and file types. It covers commands for changing directories, listing files, and viewing file contents. It also discusses wildcards, regular expressions, and text editors like vi that are used for viewing and editing files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Chapter 3

1 Exploring Linux
Filesystems
2

 Describe a file system?


 What types of file can you have?
 What is a binary file?
 How could you search a 4TB hard drive for a social
security number?
3 The Linux Directory Structure

 Directory: Used to organize other files into a logical tree structure


 Absolute pathname: Pathname from the root directory to a certain
file or directory
 Root: The top level directory
 the / character
 Forms root of a hierarchical tree
4 The Linux Directory Structure
5 Changing Directories

 Home directory: unique to each user account


 ~ metacharacter can be used to refer to home directory
 pwd (print working directory) command: displays current
directory in the directory tree
 cd (change directory) command: change the current directory in
the directory tree
 Relative pathname: pathname of file or directory relative to
current directory
6 Changing Directories

 Parent directory: directory one step closer to the root of the tree
 Referred to by .. (two dots)
 Subdirectory: directory residing within another directory
 Tab-completion: pressing the Tab key fills in remaining
characters of a unique filename, directory name, or executable
program
7 File Types

 Text files: store information in a readable text format, contain


configuration information
 Binary data files: store information associated with executable
programs
 Executable program files
 Directory files: serve as placeholders to organize other files
8 File Types

 Linked files: files that have an association with one another


 Special device files: represent devices on the system, such as
hard disks and serial ports
 Named pipes files: identify a channel that passes information
between processes
 Socket files: allow a process on another computer to write to a
local file
 A variant of a named pipe file
9 Filenames

 Filename: identifier given to a file


 Up to 255 characters (rarely longer than 20 characters)
 Can use alphanumeric characters, underscore (_), dash (-), and period
(.)
 Filename extensions: identifiers following a dot (.) at end of
filename
 Denote file type
 Most files on Linux do not have filename extensions
10 Filenames
11 Listing Files

 ls command: List the files in a directory


 May pass an argument indicating the directory to be listed
 –F option: Argument to view of list of files and their type
 –l option: Argument to provide a long listing for each file in a certain
directory
12 Listing Files

 File command: displays file type of any file


 Argument indicates what file or files to analyze
 Identifies between different types of executable files
 Identifies empty files
 Hidden files: files not normally displayed to user
 Configuration files often hidden
 Filenames start with a dot (.)
 ls –a command: displays hidden files
 To view all hidden files and their file types, type:
 ls -aF
13 Wildcard Metacharacters

 Wildcard metacharacter: used to simplify commands specifying


more than one filename on the command line
 Can match the entire filename or portions of filenames
 Can be used with most Linux filesystem commands
14 Displaying Content of Text Files

 Users can use keyboard shortcuts to interact with shell while


using the less command.
 e.g., pressing h key gets Help screen
 e.g., pressing q key quits the less command
 more and less can be used with output of other commands
 If output is too large to fit on terminal screen, use “|” metacharacter
and more or less command
 e.g., ls -l | more
15 Displaying the Contents of Binary
Files
 To view contents of binary files, you typically use the program
that created the file
 strings command: searches for and displays text characters in
a binary file
 Might indicate purpose of binary file
16 Regular Expressions

 Different from wildcard metacharacters


 Wildcard metacharacters are interpreted by shell; regexps interpreted
by text tools
 Wildcard metacharacters match characters in filenames; regexps
match characters within text files
 Wildcard metacharacters typically have different definitions than
regexps
 More regexps than wildcard metacharacters
17

If \d represents a digit, what is this? \d{3}-\d{2}-\d{4}


18 The grep Command
 grep (global regular expression print) command: searches lines
in a text file that match common regexps

 grep is case sensitive


 For case-insensitive search, use –i option
 grep matches patterns of text, ignoring division into words
 To search only for occurrences of a word, surround it by space
characters

grep –i something /directory/filename


grep ^root /etc/passwd
19 Editing Text Files
 Most system configuration is stored in text files
 Most Linux distributions come with several text editors
 Text editors come in two varieties:
 command line
 GUI
 Vi
 Advantage is portability, not usability
 Used on Unix and Linux
 supports regular expressions
 perform over 1000 different functions for the user

CompTIA Linux+ Guide to Linux Certification, Fourth Edition


20 The vi Editor
 Command mode: Performs text editing tasks not related to inserting text
 Such as deleting text, copying text, saving changes to a file, and exiting the vi editor

 Insert mode: Inserts text, but nothing else


 Press the Esc key to return to command mode
21 The vi Editor
22 Other Common Text Editors
 gedit editor: a graphical text editor functional in a GUI
environment
 Does not have advanced functionality like vi and Emacs
 Easiest editor to use
23 Summary
 The Linux filesystem is arranged hierarchically using a series of directories to store files
 Location of directories and files can be described using absolute or relative pathnames
 Linux filesystem can contain many types of files
 text files, binary data, executable programs, directories, linked files, and special device files
 The ls command is used to view filenames
 Wide range of options to modify views
 Wildcard metacharacters are special keyboard characters
 can simplify selection of several files when using common Linux file commands
 Text files are the most common file type whose contents can be viewed by several
utilities, such as head, tail, cat, tac, more, and less
 Regular expression metacharacters can be used to specify certain patterns of text
 When used with certain programming languages and text tool utilities such as grep
 Although many command-line and graphical text editors exist, vi (vim) is a powerful,
bimodal text editor that is standard on most UNIX and Linux systems

You might also like