Linux+ Guide to Linux Certification, Third Edition

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

RH030 Linux Computing Essentials
A Guide to Unix Using Linux Fourth Edition
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
Exploring the UNIX File System and File Security
Linux+ Guide to Linux Certification, Second Edition
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
The UNIX File System.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Linux+ Guide to Linux Certification Chapter Three Linux Installation and Usage.
Advanced File Processing
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Chapter 3 Mastering Editors
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Linux+ Guide to Linux Certification, Second Edition
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Third Edition
Chapter Two Exploring the UNIX File System and File Security.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Chapter Three The UNIX Editors.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop III - Part A Shell Commands Professional Training.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Second Edition
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Operating Systems and Using Linux Courtesy of John Y. Park 1.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
Linux Administration Working with the BASH Shell.
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Lesson 5-Exploring Utilities
SUSE Linux Enterprise Desktop Administration
Prepared by: Eng. Maryam Adel Abdel-Hady
C151 Multi-User Operating Systems
Guide To UNIX Using Linux Third Edition
Exploring the UNIX File System and File Security
Guide To UNIX Using Linux Third Edition
Chapter Four UNIX File Processing.
Linux Operations and Administration
Presentation transcript:

Linux+ Guide to Linux Certification, Third Edition Chapter 3 Exploring Linux Filesystems

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 Linux+ Guide to Linux Certification, 3e

Objectives (continued) Display the contents of text files and binary files 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 Linux+ Guide to Linux Certification, 3e

The Linux Directory Structure Directory: Used to organize other files into a logical tree structure Stored in a filesystem of a specific partition in the hard disk Absolute pathname: Pathname from the root directory to a certain file or directory Root: The top level directory Referred to using the / character Forms root of a hierarchical tree Linux+ Guide to Linux Certification, 3e

The Linux Directory Structure (continued) Figure 3-1: The Windows filesystem structure Figure 3-2: The Linux filesystem structure Linux+ Guide to Linux Certification, 3e

Changing Directories Home directory: unique to each user ~ metacharacter 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 Argument specifies the destination directory Relative pathname: pathname of file or directory relative to current directory Linux+ Guide to Linux Certification, 3e

Changing Directories (continued) 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 or directory name BASH shell feature Alerts user if there is more than one possible match Linux+ Guide to Linux Certification, 3e

Viewing Files and Directories: 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 Linux+ Guide to Linux Certification, 3e

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 Linux+ Guide to Linux Certification, 3e

Filenames Filename: identifier given to a file Up to 255 characters Can use alphanumeric characters, dash (-), underscore (_), and dot (.) Filename extensions: identifiers following a dot (.) at end of filename Denote file type Most files on Linux do not have filename extensions Linux+ Guide to Linux Certification, 3e

Table 3-1: Common filename extensions Linux+ Guide to Linux Certification, 3e

Listing Files ls command: List the files in a directory May pass an argument indicating the directory to be listed –F option: Argument to indicate file types –l option: Argument to list long file listings Linux+ Guide to Linux Certification, 3e

Listing Files (continued) Long listing for each file includes eight components File type character List of permissions (mode of the file) Hard link count Owner Group owner File size Most recent modification time Filename Linux+ Guide to Linux Certification, 3e

Listing Files (continued) Alias: shortcut for a command ll command: Alias for ls -l 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 Linux+ Guide to Linux Certification, 3e

Listing Files (continued) Table 3-2: Common options to the ls command Linux+ Guide to Linux Certification, 3e

Listing Files (continued) Table 3-2 (continued): Common options to the ls command Linux+ Guide to Linux Certification, 3e

Wildcard Metacharacters Wildcard metacharacter: used to simplify commands specifying multiple filenames Can match the entire filename or portions of filenames Can be used with most Linux filesystem commands Linux+ Guide to Linux Certification, 3e

Wildcard Metacharacters (continued) Table 3-3: Wildcard metacharacters Linux+ Guide to Linux Certification, 3e

Displaying Content of Text Files Concatenation: joining text together cat command: displays (concatenates) contents of a text file to the screen -n option: displays line number and contents Log files: contain records of past system events New events appended to end tac command: displays contents of a text file in reverse order Linux+ Guide to Linux Certification, 3e

Displaying Content of Text Files (Continued) head command: view first ten lines of a file tail command: view last ten lines of a file For head and tail commands Line count includes blank lines Can provide numeric option to specify the number of lines to be displayed (e.g., head -2 filename) Linux+ Guide to Linux Certification, 3e

Displaying Content of Text Files (continued) Large text files can not be viewed using the cat command, because the screen will only fit a portion of the file more command: displays text files page-by-page Pressing Spacebar displays the next page Pressing Enter displays the next line less command: same as more command, but can also use cursor to scroll Linux+ Guide to Linux Certification, 3e

Displaying Content of Text Files (continued) Users can use keyboard shortcuts to interact with shell while in more and less commands. e.g., pressing h key gets Help screen e.g., pressing q key quits more and less commands 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 Linux+ Guide to Linux Certification, 3e

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) -x option displays contents of the file in hexadecimal format (numeric base 16 format) Linux+ Guide to Linux Certification, 3e

Searching for Text Within Files Text tools: commands that search for and manipulate text Regular expressions (regexp): text wildcards that ease the search for specific text Match patterns of text within a text document Used by many text tools and programming languages Including grep, emacs, C++, PERL, and many more Linux+ Guide to Linux Certification, 3e

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 Wildcard metacharacters have different definitions that regexps More regexps than wildcard metacharacters Regular expressions are divided into common regexps and extended regexps Linux+ Guide to Linux Certification, 3e

Table 3-4: Regular expressions Linux+ Guide to Linux Certification, 3e

The grep Command grep (global regular expression print) command: displays lines in a text file that match common regexps egrep command: displays lines in a text file that match extended regexps Can be written as grep -E fgrep command: does not interpret any regular expressions Returns results much faster than egrep Can be written as grep -F Linux+ Guide to Linux Certification, 3e

The grep Command (continued) grep requires two arguments Text to search for Can use regular expressions Files in which to search 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 Linux+ Guide to Linux Certification, 3e

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 Linux+ Guide to Linux Certification, 3e

Editing Text Files: The vi Editor (continued) Table 3-5: Common keyboard keys used to change to and from insert mode Linux+ Guide to Linux Certification, 3e

Editing Text Files: The vi Editor (continued) Table 3-6: Key combinations commonly used in command mode Linux+ Guide to Linux Certification, 3e

Editing Text Files: The vi Editor (continued) Table 3-6 (continued): Key combinations commonly used in command mode Linux+ Guide to Linux Certification, 3e

Editing Text Files: The vi Editor (continued) Table 3-6 (continued): Key combinations commonly used in command mode Linux+ Guide to Linux Certification, 3e

Editing Text Files: The vi Editor (continued) Table 3-7: Key combinations commonly used at the command mode : prompt Linux+ Guide to Linux Certification, 3e

Other Common Text Editors Emacs (Editor MACroS) editor: comparable functionality to vi Ctrl key combinations to perform special functions Supports LISP (LISt Processing) artificial intelligence programming language Emacs editor is not easy to use Must memorize key combination Emacs can be run in a GUI environment to get a graphical version of the editor Much easier to use; icons replace key combinations Linux+ Guide to Linux Certification, 3e

Other Common Text Editors (continued) Table 3-8: Keyboard functions commonly used in the GNU Emacs editor Linux+ Guide to Linux Certification, 3e

Other Common Text Editors (continued) Figure 3-3: A graphical Emacs session Linux+ Guide to Linux Certification, 3e

Other Common Text Editors (continued) Nano editor: text editor that uses Ctrl key combinations for performing functions Based on the pine UNIX editor Ctrl key combinations listed at the bottom of the screen Very basic and easy-to-use Used by Linux administrators to modify files when advanced functionality is not needed Linux+ Guide to Linux Certification, 3e

Other Common Text Editors (continued) gedit editor: a graphical text editor functional in a GUI environment Does not have advanced functionality like vi and Emacs Easiest editor to use Functionality is analogous to the Windows Wordpad and Notepad editors Linux+ Guide to Linux Certification, 3e

Other Common Text Editors (continued) Figure 3-4: The gedit text editor Linux+ Guide to Linux Certification, 3e

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 Linux+ Guide to Linux Certification, 3e

Summary (continued) 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 Linux+ Guide to Linux Certification, 3e

Summary (continued) Regular expression metacharacters can be used to specify certain patterns of text 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 Linux+ Guide to Linux Certification, 3e