Download presentation
Presentation is loading. Please wait.
Published byAugustus Owens Modified over 9 years ago
1
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems
2
Objectives Understand and navigate the Linux directory structure using relative and absolute pathnames Describe the various types of Linux files View filenames and file types Use shell wildcards to specify multiple filenames Display the contents of text files and binary files Search text files for regular expressions using grep Identify common text editors used today Use the vi editor to manipulate text files
3
The Linux Directory Structure Directory –Special file on the filesystem used to organize other files into a logical tree structure Figure 4-1: The Windows filesystem structure
4
The Linux Directory Structure Absolute pathname –Full pathname to a certain file or directory starting from the root directory Figure 4-2: The Linux filesystem structure
5
Changing Directories Home directory –A directory on the file system set aside for users to store personal files and information pwd command (print working directory) –Linux command used to display the current directory in the directory tree cd (change directory) command –Linux command used to change the current directory in the directory tree
6
Changing Directories ~ metacharacter –Can be used to refer to the current user’s home directory –Can be used to specify another user’s home directory by appending a username at the end of the ~ metacharacter Relative pathname –Pathname of a target directory relative to your current directory in the tree
7
Changing Directories Subdirectory –Directory that resides within another directory in the directory tree Tab-completion –Feature of the BASH Shell that fills in the remaining characters of a unique filename or directory name when the user presses the Tab key
8
File Types Common file types: –Text files –Binary data files –Executable program files –Directory files –Linked files –Special device files –Named pipes and socket files
9
Filenames Filename –User-friendly identifier given to a file Executable programs –File that can be executed by the Linux OS to run in memory as a process and perform a useful function Filename extensions –Series of identifiers following a dot (.) at the end of a filename used to denote the type of the file
10
Filenames Table 4-1: Common filename extensions
11
Filenames Table 4-1 (continued): Common filename extensions
12
Filenames
13
Listing Files ls command –Linux command used to list the files in a given directory –Most common method for displaying files –Displays all the files in the current directory in columnar format However, you may also pass an argument to the ls command indicating the directory to be listed if different from current directory listing
14
Listing Files ll command –Alias for the ls -l command –Gives a long file listing File command –Linux command that displays the file type of a specified filename
15
Listing Files Text file –File that stores information in a readable text format Some filenames inside each user’s home directory represent important configuration files or program directories Hidden files –Files that are not normally displayed to the user via common filesystem commands
16
Listing Files Table 4-2: Common options to the ls command
17
Listing Files Table 4-2 (continued): Common options to the ls command
18
Wildcard Metacharacters Wildcard metacharacter –Can simplify commands that specify more than one filename on the command line –Interpreted by the shell and can be used with most common Linux filesystem commands –Matches certain portions of filenames, or the entire filename itself
19
Wildcard Metacharacters Table 4-3: Wildcard metacharacters
20
Displaying Content of Text Files Concatenation –Joining of text together to make one larger whole –In Linux, words and strings of text are joined together to form a displayed file cat command –Linux command used to display (or concatenate) the entire contents of a text file to the screen
21
Displaying Content of Text Files Log files –File that contains past system events tac command –Linux command that displays a file to the screen beginning with the last line of the file and ending with the first line of the file
22
Displaying Content of Text Files head command –By default, displays the first 10 lines (including blank lines) of a text file to the terminal screen –Can also take a numeric option specifying a different number of lines to display tail command –By default, displays the last 10 lines (including blank lines) of a text file to the terminal screen –Can also take a numeric option specifying a different number of lines to display
23
Displaying Content of Text Files more command –Linux command used to display a text file page- by-page and line-by-line on the terminal screen –Gets its name from the pg command once used on UNIX system –The more command does more than pg did
24
Displaying Content of Text Files less command –Linux command used to display to display a text file page-by-page on the terminal screen –Users may then use the cursor keys to navigate the file The more and less commands can also be used in conjunction with the output of other commands if that output is too large to fit on the terminal screen
25
Displaying the Contents of Binary Files It is important to employ text file commands as cat, tac, head, tail, more, and less only on files that contain text –Otherwise you may find yourself with random output on the terminal screen, or even a dysfunctional screen strings commands –Linux command used to search for and display text characters in a binary file
26
Displaying the Contents of Binary Files od command –Linux command that is used to display the contents of a file in octal format (numeric base 8 format) –Safe to use on binary files and text files
27
Searching for Text within Files Text tools –File that stores information in a readable text format Regular expressions (regxp) –Special metacharacters used to match patterns of text within text files –Commonly used by many text tool commands such as grep
28
Searching for Text within Files Text tools and programming languages that use regular expressions include: –grep –awk –sed –vi –emacs
29
Searching for Text within Files Text tools and programming languages that use regular expressions include (continued): –ex –ed –C++ –PERL –Tcl
30
Regular Expressions Differences between regular expressions and wildcard metacharacters include: –Wildcard metacharacters are interpreted by the shell Regular expressions are interpreted by a text tool program –Wildcard metacharacters match characters in filenames (or directory names) on a Linux filesystem Regular expressions match characters within text files on a Linux filesystem
31
Regular Expressions Differences between regular expressions and wildcard metacharacters include (continued): –Wildcard metacharacters typically have different definitions than regular expressions –There are more regular expressions than wildcard metacharacters –Regular expressions are divided into two different categories: Common extended
32
Regular Expressions Table 4-4: Regular expressions
33
Regular Expressions Table 4-4 (continued): Regular expressions
34
The grep Command grep –Stands for Global Regular Expression Print –Used to display lines in a text file that match a certain common regular expression Use the egrep command to display lines of text that match extended regular expressions The fgrep command does interpret any regular expressions and consequently returns results much faster than the egrep command
35
The vi Editor One of the oldest and most popular visual text editors available for UNIX operating systems –Its Linux equivalent (known as vim—vi improved) is standard on almost every Linux distribution as a result Though not the easiest of the editors to use when editing text files, it has the advantage of portability
36
The vi Editor The vi editor is called a bi-modal editor as it functions in one of two modes: –Command mode Allows a user to perform any available text editing task that is not related to inserting text into the document –Insert mode Allows the user to insert text into the document but does not allow any other functionality
37
The vi Editor Table 4-5: Common keyboard keys used to change to and from insert mode
38
The vi Editor Table 4-6: Key combinations commonly used in command mode
39
The vi Editor Table 4-6 (continued): Key combinations commonly used in command mode
40
The vi Editor Table 4-6 (continued): Key combinations commonly used in command mode
41
The vi Editor Table 4-7: Key combinations commonly used at the command mode : prompt
42
Other Common Text Editors Pico (PIne COmposer) editor –By far, the easiest alternative to the vi editor –Commonly used to create and edit e-mails Mcedit editor (Midnight Commander Editor) –Resembles pico yet had more functionality, support for regular expressions, and ability to use the mouse for highlighting text
43
Other Common Text Editors Emacs (Editor MAcroS) editor –Alternative to the vi editor that offers an equal set of functionality –Like pico, uses the Ctrl key in combination with certain letters to perform special functions Yet can be used with the LISP (LSIt Processing) artificial programming language and supports hundreds of key board functions like the vi editor
44
Other Common Text Editors Table 4-8: Keyboard functions commonly used in the GNU emacs editor
45
Other Common Text Editors The emacs editor is not an easy-to-use editor as it must memorize several key combinations to work effectively Xemacs editor –Version if emacs that runs in the KDE or GNOME GUI environments –Much easier to use than emacs
46
Other Common Text Editors Figure 4-3: The xemacs test editor
47
Other Common Text Editors The xemacs editor may not be available in every Linux distribution that contains a GUI environment Two commonly used graphical text editors available in most Linux distributions: –Xedit editor –Nedit editor
48
Other Common Text Editors Figure 4-4: The exedit text editor
49
Other Common Text Editors Figure 4-5: The nedit text editor
50
Other Common Text Editors Gedit editor –Text editor for the GNOME desktop Kedit editor –Text editor for the KDE desktop The gedit and kedit editors are similar to nedit yet offer more functionality
51
Other Common Text Editors Figure 4-6: The gedit text editor
52
Other Common Text Editors Figure 4-7: The kedit text editor
53
Chapter Summary The Linux filesystem is arranged hierarchically using a series of directories to store files, and the location of these directories and files can be described using absolute or relative pathnames There are many types of files that may exist on the Linux filesystem The ls command can be used to view filenames and offers a wide range of options to modify this view
54
Chapter Summary Wildcard metacharacters can be used to simplify the selection of several files when using common Linux file commands Text files are the common file type whose contents may be viewed by several utilities such as head, tail, cat, tac, more, and less Regular expressions can be used to specify certain patterns of text when used with certain programming languages and text tools such as grep Vi (vim) is a powerful, bi-modal text editor that is standard on most UNIX and Linux systems
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.