Download presentation
Presentation is loading. Please wait.
Published byElvin Gardner Modified over 9 years ago
1
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems
2
Linux+ Guide to Linux Certification, 2e2 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
3
Linux+ Guide to Linux Certification, 2e3 Objectives (continued) 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
4
Linux+ Guide to Linux Certification, 2e4 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 –referred to using the / character
5
Linux+ Guide to Linux Certification, 2e5 The Linux Directory Structure (continued) Figure 4-1: The Windows filesystem structure Figure 4-2: The Linux filesystem structure
6
Linux+ Guide to Linux Certification, 2e6 Changing Directories Home directory: Unique to each user pwd (print working directory) command: Displays current directory in the directory tree cd (change directory) command: Change the current directory in the directory tree ~ metacharacter: Refers to home directory Relative pathname: Pathname of file or directory relative to current directory
7
Linux+ Guide to Linux Certification, 2e7 Changing Directories (continued) Subdirectory: Directory residing within another directory Tab-completion: Pressing the Tab key fills in remaining characters of a unique filename or directory name –BASH shell feature
8
Linux+ Guide to Linux Certification, 2e8 Viewing Files and Directories: File Types Text files: Store information in a readable text format Binary data files: Store information associated with executable programs Executable program files Directory files
9
Linux+ Guide to Linux Certification, 2e9 Viewing Files and Directories: File Types (continued) Linked files: Associated with another file Special device files: Represent system devices Named pipes: Identify channel that passes information between processes Socket files: Allow a process on another computer to write to a local file
10
Linux+ Guide to Linux Certification, 2e10 Filenames Filename: Identifier given to a file Filename extensions: Identifiers following a dot (.) at end of filename –Denote file type –Most files on Linux do not have file extensions
11
Linux+ Guide to Linux Certification, 2e11 Filenames (continued) Table 4-1: Common filename extensions
12
Linux+ Guide to Linux Certification, 2e12 Filenames (continued) Table 4-1 (continued): Common filename extensions
13
Linux+ Guide to Linux Certification, 2e13 Listing Files ls command: List the files in a directory –May pass an argument indicating the directory to be listed –F switch: Argument to list file types –l switch: Argument to list long file listings Alias: Shortcut for a command ll command: Alias for ls -l File command: Displays file type of any file
14
Linux+ Guide to Linux Certification, 2e14 Listing Files (continued) Hidden files: Files not normally displayed to user –Filenames start with a dot (.) –Configuration files often hidden –ls –a command: Displays hidden files
15
Linux+ Guide to Linux Certification, 2e15 Listing Files (continued) Table 4-2: Common options to the ls command
16
Linux+ Guide to Linux Certification, 2e16 Listing Files (continued) Table 4-2 (continued): Common options to the ls command
17
Linux+ Guide to Linux Certification, 2e17 Wildcard Metacharacters Wildcard metacharacter: Used to simplify commands specifying multiple filenames –Can be used with most Linux filesystem commands
18
Linux+ Guide to Linux Certification, 2e18 Wildcard Metacharacters (continued) Table 4-3: Wildcard metacharacters
19
Linux+ Guide to Linux Certification, 2e19 Displaying Content of Text Files Concatenation: Joining text together cat command: Displays (concatenates) contents of a text file to the screen –-n switch: Displays line number and contents Log files: Contain records of past system events –New events appended to end tac command: Displays files in reverse order head command: View first few lines of a file
20
Linux+ Guide to Linux Certification, 2e20 Displaying Content of Text Files (continued) tail command: View last few lines of a file –Can also specify what line number to start at more command: Displays text files page-by-page –Space key goes to next page –Enter key goes to next line less command: Same as more command, but can also use cursor to scroll
21
Linux+ Guide to Linux Certification, 2e21 Displaying Content of Text Files (continued) more and less can be used with output of other commands –If output is too large to fit on terminal screen, use “|” metacharacter –e.g., ls -l | more
22
Linux+ Guide to Linux Certification, 2e22 Displaying the Contents of Binary Files Typically use program that created the file strings command: Searches for and displays text characters in a binary file –Might indicate purpose of binary file od command: Displays contents of file in octal format (numeric base 8 format)
23
Linux+ Guide to Linux Certification, 2e23 Searching for Text Within Files Text tools: Search for and manipulate text Regular expressions (regexp): Text wildcards that assist search for specific text –Match patterns of text –Used by many text tools and programming languages Including grep, emacs, C++, PERL, and many more
24
Linux+ Guide to Linux Certification, 2e24 Regular Expressions Different from wildcard metacharacters –Wildcard metacharacters interpreted by shell; regexps interpreted by text tools –Wildcard metacharacters match characters in filenames; regexps match characters within text files –More regexps than wildcard metacharacters Common and extended regexps
25
Linux+ Guide to Linux Certification, 2e25 Regular Expressions (continued) Table 4-4: Regular expressions
26
Linux+ Guide to Linux Certification, 2e26 Regular Expressions (continued) Table 4-4 (continued): Regular expressions
27
Linux+ Guide to Linux Certification, 2e27 The grep Command grep (global regular expression print) command: Displays lines in a text file matching a given regexp egrep command: Displays lines of text that match extended regexps fgrep command: Does not interpret any regular expressions –Returns results much faster than egrep grep requires two arguments –Text to search for and files to search
28
Linux+ Guide to Linux Certification, 2e28 Editing Text Files: The vi Editor One of the oldest and most popular text editors for UNIX OSs Vim: Linux equivalent of vi –Standard on most Linux distributions Advantage is portability, not usability –Used on Unix and Linux Bi-modal editor (two possible modes): –Command mode: Performs text editing tasks not related to inserting text –Insert mode: Inserts text, but nothing else User environment is customizable
29
Linux+ Guide to Linux Certification, 2e29 Editing Text Files: The vi Editor (continued) Table 4-5: Common keyboard keys used to change to and from insert mode
30
Linux+ Guide to Linux Certification, 2e30 Editing Text Files: The vi Editor (continued) Table 4-6: Key combinations commonly used in command mode
31
Linux+ Guide to Linux Certification, 2e31 Editing Text Files: The vi Editor (continued) Table 4-6 (continued): Key combinations commonly used in command mode
32
Linux+ Guide to Linux Certification, 2e32 Editing Text Files: The vi Editor (continued) Table 4-6 (continued): Key combinations commonly used in command mode
33
Linux+ Guide to Linux Certification, 2e33 Editing Text Files: The vi Editor (continued) Table 4-7: Key combinations commonly used at the command mode : prompt
34
Linux+ Guide to Linux Certification, 2e34 Other Common Text Editors Mcedit editor (Midnight Commander Editor): Easy- to-use text editor –Supports regexp –Supports use of mouse for highlighting text Emacs (Editor MACroS) editor: Comparable functionality to vi –Ctrl key combinations to perform special functions –Supports LISP (LISt Processing) artificial intelligence programming language
35
Linux+ Guide to Linux Certification, 2e35 Other Common Text Editors (continued) Table 4-8: Keyboard functions commonly used in the GNU emacs editor
36
Linux+ Guide to Linux Certification, 2e36 Other Common Text Editors (continued) Emacs editor is not easy to use –Must memorize key combinations Xemacs editor: Version of Emacs for KDE or GNOME GUI environments –Easier to use than emacs –Not available with every distribution
37
Linux+ Guide to Linux Certification, 2e37 Other Common Text Editors (continued) Figure 4-3: The xemacs text editor
38
Linux+ Guide to Linux Certification, 2e38 Other Common Text Editors (continued) Graphical text editors available with most Linux distributions: –nedit editor –gedit editor: Distributed with GNOME environment –kedit editor: Distributed with KDE environment gedit and kedit offer more functionality than nedit
39
Linux+ Guide to Linux Certification, 2e39 Other Common Text Editors (continued) Figure 4-4: The nedit text editor
40
Linux+ Guide to Linux Certification, 2e40 Other Common Text Editors (continued) Figure 4-5: The gedit text editor
41
Linux+ Guide to Linux Certification, 2e41 Other Common Text Editors (continued) Figure 4-6: The kedit text editor
42
Linux+ Guide to Linux Certification, 2e42 Summary The Linux filesystem is arranged hierarchically using a series of directories to store files Location of these directories and files can be described using absolute or relative pathnames Accommodates 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 Wildcard metacharacters can simplify selection of several files when using common Linux file commands
43
Linux+ Guide to Linux Certification, 2e43 Summary (continued) 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 vi (vim) is a powerful, bimodal text editor that is standard on most UNIX and Linux systems
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.