Podcast
Questions and Answers
What is the term for a pathname that starts from the root directory?
What is the term for a pathname that starts from the root directory?
- Home directory
- Current directory
- Relative pathname
- Absolute pathname (correct)
In Linux, what is the top-level directory known as?
In Linux, what is the top-level directory known as?
- Home
- Base
- Root (correct)
- Top
Which character represents the root directory in Linux?
Which character represents the root directory in Linux?
- / (correct)
- .
- \
- ~
What is the primary function of a directory in Linux?
What is the primary function of a directory in Linux?
On what type of storage is a filesystem typically stored?
On what type of storage is a filesystem typically stored?
Which of the following is NOT true about the Linux directory structure?
Which of the following is NOT true about the Linux directory structure?
What is the opposite of an absolute pathname?
What is the opposite of an absolute pathname?
Which command displays lines matching extended regular expressions?
Which command displays lines matching extended regular expressions?
What are the two arguments required by the grep
command?
What are the two arguments required by the grep
command?
If you need to perform a case-insensitive search using grep
, what option should you use?
If you need to perform a case-insensitive search using grep
, what option should you use?
What is the purpose of the pwd
command?
What is the purpose of the pwd
command?
Which text editor is considered the Linux equivalent of vi
?
Which text editor is considered the Linux equivalent of vi
?
Which metacharacter is used to refer to a user's home directory?
Which metacharacter is used to refer to a user's home directory?
What is a subdirectory?
What is a subdirectory?
What is a primary advantage of using the vi
editor?
What is a primary advantage of using the vi
editor?
What does the cd
command do?
What does the cd
command do?
What is a relative pathname?
What is a relative pathname?
How do you refer to the parent directory?
How do you refer to the parent directory?
Which shell feature fills in the remaining characters when pressing the Tab key?
Which shell feature fills in the remaining characters when pressing the Tab key?
Which of the following is a type of file that contains configuration information?
Which of the following is a type of file that contains configuration information?
Which wildcard metacharacter matches exactly one character in a filename?
Which wildcard metacharacter matches exactly one character in a filename?
What is the main goal of a directory structure?
What is the main goal of a directory structure?
Which command displays the contents of a text file?
Which command displays the contents of a text file?
Which command displays the contents of a text file in reverse order?
Which command displays the contents of a text file in reverse order?
Which command displays the first ten lines of a file?
Which command displays the first ten lines of a file?
Which of the following is NOT a function of the less
command?
Which of the following is NOT a function of the less
command?
Which command is most suitable for viewing large text files?
Which command is most suitable for viewing large text files?
What type of files contain records of events?
What type of files contain records of events?
Which wildcard metacharacter matches zero or more characters?
Which wildcard metacharacter matches zero or more characters?
Which option, when used with the cat
command, displays the line number of each line in the file?
Which option, when used with the cat
command, displays the line number of each line in the file?
What is the maximum length of a filename in Linux?
What is the maximum length of a filename in Linux?
Which characters are commonly allowed in Linux filenames?
Which characters are commonly allowed in Linux filenames?
What is the purpose of a filename extension?
What is the purpose of a filename extension?
Which command displays files in a directory?
Which command displays files in a directory?
Which command provides a long listing of files?
Which command provides a long listing of files?
Which file component is included in the long listing?
Which file component is included in the long listing?
Which command displays the file type?
Which command displays the file type?
How are hidden files named?
How are hidden files named?
Which command shows hidden files?
Which command shows hidden files?
Flashcards
Directory
Directory
A method of organizing files into a hierarchical, tree-like structure.
Root Directory
Root Directory
A directory that serves as the starting point for all files and directories in the filesystem.
Absolute Pathname
Absolute Pathname
The complete path from the root directory to a specific file or directory.
Relative Pathname
Relative Pathname
Signup and view all the flashcards
Filesystem
Filesystem
Signup and view all the flashcards
Hard Disk Drive (HDD)
Hard Disk Drive (HDD)
Signup and view all the flashcards
Solid State Drive (SSD)
Solid State Drive (SSD)
Signup and view all the flashcards
Home directory
Home directory
Signup and view all the flashcards
pwd command
pwd command
Signup and view all the flashcards
cd command
cd command
Signup and view all the flashcards
Parent directory
Parent directory
Signup and view all the flashcards
Subdirectory
Subdirectory
Signup and view all the flashcards
Tab-completion
Tab-completion
Signup and view all the flashcards
Text files
Text files
Signup and view all the flashcards
Special device files
Special device files
Signup and view all the flashcards
grep command
grep command
Signup and view all the flashcards
egrep command
egrep command
Signup and view all the flashcards
fgrep command
fgrep command
Signup and view all the flashcards
vi/vim editor
vi/vim editor
Signup and view all the flashcards
Filename
Filename
Signup and view all the flashcards
Filename extension
Filename extension
Signup and view all the flashcards
ls -F
ls -F
Signup and view all the flashcards
ls -l
ls -l
Signup and view all the flashcards
File components (ls -l)
File components (ls -l)
Signup and view all the flashcards
file command
file command
Signup and view all the flashcards
Hidden files
Hidden files
Signup and view all the flashcards
ls -a
ls -a
Signup and view all the flashcards
Wildcard metacharacters
Wildcard metacharacters
Signup and view all the flashcards
Wildcard: *
Wildcard: *
Signup and view all the flashcards
Wildcard: ?
Wildcard: ?
Signup and view all the flashcards
Wildcard: [aegh]
Wildcard: [aegh]
Signup and view all the flashcards
Wildcard: [a-e]
Wildcard: [a-e]
Signup and view all the flashcards
Wildcard: [!a-e]
Wildcard: [!a-e]
Signup and view all the flashcards
tac command
tac command
Signup and view all the flashcards
head command
head command
Signup and view all the flashcards
tail command
tail command
Signup and view all the flashcards
less command
less command
Signup and view all the flashcards
Study Notes
Exploring Linux Filesystems
- Understand and navigate the Linux directory structure using relative and absolute pathnames.
- Describe the various types of Linux files.
- View filenames and file types.
- Employ shell wildcards to specify multiple filenames.
- Display the contents of various types of files, including text and binary.
- Search text files for regular expressions using grep.
- Use the vi editor to manipulate text files.
- Identify common alternatives to the vi text editor used today.
The Linux Directory Structure
- A directory organizes files into a logical tree structure and is stored in a filesystem on a specific partition of a hard disk or SSD.
- An absolute pathname provides the path from the root directory to a specific file or directory.
- Root refers to the top-level directory, designated as /root.
Changing Directories
- Each user account has a home directory, the ~ metacharacter refers to this directory.
- The pwd command displays the current directory within the directory tree.
- The cd command changes the current directory.
- A relative pathname specifies the path of a target file or directory relative to the current directory.
- A parent directory is one step closer to the root of the tree and is referenced by two dots (..).
- A subdirectory resides within another directory.
- Tab-completion is a BASH shell feature where pressing the Tab key fills in the remaining characters and alerts the user if multiple matches are possible.
Viewing Files and Directories
- A directory structure organizes files into an easy-to-use format.
- Viewing files and directories involves recognizing various file types, filenames, and commands to select filenames for viewing.
File Types
- Text files contain configuration information.
- Binary data files store information like common functions and graphics
- Linked files have an association with one another.
- Special device files represent different devices on the system.
- Named pipe files identify channels that pass information from one process in memory to another.
- Socket files allow a process on another computer to write to a file on the local computer while another process reads from that file.
Filenames
- A filename is an identifier given to a file, with a length of up to 255 characters (though rarely longer than 20).
- Filenames can contain alphanumeric characters, underscores (_), dashes (-), and periods (.).
- Filename extensions are identifiers following a period (.) at the end of the filename to indicate the file type.
- Most files on Linux do not have filename extensions.
Listing Files
- The ls command displays files in a directory.
- The ls -F command appends a special character at the end of each filename to indicate the file type.
- The ls -l command provides a long listing for each file in a certain directory.
- File components listed with ls -l include the file type character, file permissions, hard link count, owner, group owner, size, modification time, and filename.
- The file command displays the file type of any file, using an argument to specify which file(s) to analyze.
- The file command identifies different types of executable files and empty files.
- Hidden files are not normally displayed to the user and are often configuration files.
- Filenames that start with a dot (.) are hidden.
- The ls -a command displays hidden files.
Wildcard Metacharacters
- Simplify commands by enabling specification of multiple filenames on the command line.
- They can match the entire filename or portions of filenames.
- They can be used with most Linux filesystem commands.
- *: Matches 0 or more characters in a filename.
- ?: Matches 1 character in a filename.
- [aegh]: Matches 1 character, if it is a, e, g, or h.
- [a-e]: Matches 1 character, if it is a, b, c, d, or e.
- [!a-e]: Matches 1 character, if it is NOT a, b, c, d, or e.
Displaying the Contents of Text Files
- Concatenation views an entire text file on the terminal screen,.
- The cat command displays the contents of a text file to the screen.
- The cat -n option displays the line number of each line in the file.
- Log files contain records of events, with the most recent events appended to the end of the file.
- The tac command displays the contents of a text file in reverse order.
- The head command displays the first ten lines of a file.
- The tail command displays the last ten lines of a file.
- Large text files cannot be viewed using the cat command because the screen can display only a portion.
- The more command displays text files page-by-page.
- The less command has the same functionality as more but has the added feature of allowing navigation using arrow keys.
- The more and less commands can be used with output of other commands.
Displaying the Contents of Binary Files
- To view the contents of binary files, you can use the program used to create the file.
- The strings command searches for and displays text characters in a binary file and might indicate the binary file's purpose.
- The od command displays contents of a file in octal format (numeric base 8).
- The od -x option displays the contents in hexadecimal format (numeric base 16).
Searching for Text Within Files
- Text tools include commands that search for and manipulate text, such as database information.
- Regular expressions (regexp) are text wildcards used to ease the search for specific text.
- Regular expressions are recognized by several text tools and programming languages.
Regular Expressions
- Regular expressions are different from wildcard metacharacters.
- Wildcard metacharacters are interpreted by the shell, while regular expressions are interpreted by a text tool program.
- Wildcard metacharacters match characters in filenames (or directory names) while regular expressions match characters within text files.
- Wildcard metacharacters and regular expressions have different definitions.
- There are many more regular expression metacharacters available than wildcard metacharacters.
- Regular expressions fall into two categories: common and extended.
- Common regular expressions are available to most text tools.
- Extended regular expressions are less common and available in certain text tools only.
The grep Command
- Is a global regular expression print command that displays lines in a text file that match common regular expressions.
- The egrep command displays lines that match extended regular expressions.
- The fgrep command does not interpret regular expressions and therefore returns results much faster.
- It requires two arguments: text to search and files to search.
- It is case sensitive.
- The -i option is used for case-insensitive searches.
- It matches patterns of text, but cannot discern words or phrases unless they are specified.
Editing Text Files
- Most system configurations are stored in text files because they contain often-accessed information such as e-mail and program source code.
- Most Linux distributions include multiple text editors that can be used on the command line or in a GUI environment.
The vi Editor
- Is a popular text editor for UNIX OSs.
- The Linux equivalent of vi is vim (vi improved).
- Because it is standard on most Linux distributions and used on Unix and Linux, its advantage is portability, not usability.
- The vi editor supports regular expressions and can perform over 1000 different functions.
- The vi editor is a bi-modal editor.
- Command mode allows text editing tasks not related to inserting text, such as deleting text, copying text, saving changes, and exiting.
- Insert mode inserts text.
- The Esc key returns to command mode.
- Its user environment can be customized through settings at the : prompt.
Other Common Text Editors
- GNU Emacs (Editor MACroS) offers comparable functionality to vi.
- Nano uses Ctrl key combinations for performing functions.
- Gedit is a functional graphical text editor in a GUI environment.
Summary of Linux Filesystems
- The Linux filesystem is arranged hierarchically, with a series of directories that store files.
- The ls command provides an option to modify the view to display filenames,
- Wildcard metacharacters are special keyboard characters that simplify selecting files when using common Linux file commands.
- Text files are the most common file type, and several utilities can display their contents: head, tail, cat, tac, more, and less.
- Regular expression metacharacters are used to specify certain patterns of text.
- Commonly used with certain programming languages and text tool utilities like grep.
- Although command-line and graphical text editors exist, vi (vim) is a powerful bimodal text editor standard on most UNIX and Linux systems.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.