Linux+ Guide to Linux Certification Chapter Six Linux Filesystem Administration.
The Complete Guide for Linux System Administration CH03 powerpoint
-
Upload
wannabeef9 -
Category
Documents
-
view
910 -
download
2
description
Transcript of The Complete Guide for Linux System Administration CH03 powerpoint
![Page 1: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/1.jpg)
Chapter 3:Using the Shell
The Complete Guide to Linux System Administration
![Page 2: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/2.jpg)
The Complete Guide to Linux System Administration 2
Objectives
• Use common features of the shell to work at the command line
• Manipulate variables in the shell to control your working environment
• Redirect data at the command line
• Edit text using the vi editor
• Print basic files from the command line
![Page 3: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/3.jpg)
The Complete Guide to Linux System Administration 3
Exploring the Bash Shell
• Shell – Command program – Accepts input from keyboard – Uses input to run commands or otherwise control
computer– Started when terminal window opened
![Page 4: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/4.jpg)
The Complete Guide to Linux System Administration 4
Exploring the Bash Shell (continued)
• Flexible– Interact with any file that you have permission to
access– Start any program on system– Use special features of shell to work more
efficiently
![Page 5: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/5.jpg)
The Complete Guide to Linux System Administration 5
The Shell Prompt
• Set of words or characters indicating that shell is ready to accept commands
• Default prompt example:– [Nwells@inverness nwells]$
• When logged in as root, prompt character changes to hash mark, #
![Page 6: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/6.jpg)
The Complete Guide to Linux System Administration 6
The Functions of a Shell
• Shell purpose– Make it easy for users to run programs and work
with files in Linux– Run programs– Pass parameters to program being started
• Behavior– If command succeeds, no response– If command fails, error message printed
![Page 7: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/7.jpg)
The Complete Guide to Linux System Administration 7
The Functions of a Shell (continued)
• Shell has many built-in features – Help you work with files and commands
• Script – Program– List of commands stored in text file
![Page 8: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/8.jpg)
The Complete Guide to Linux System Administration 8
Different Types of Shells
• Shell has no special relationship to Linux kernel– Can use any shell
• Bourne shell– Original shell for UNIX– Called sh– Old program with limited functionality
• Bash– Default shell for all Linux systems
![Page 9: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/9.jpg)
The Complete Guide to Linux System Administration 9
Different Types of Shells (continued)
• Shells fall into two groups:– Bourne shell programming style– C shell programming style
• Shell started for each user is determined by settings in user account– Each user on system can select preferred shell
• Immediately run different shell– Enter name of shell program
![Page 10: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/10.jpg)
The Complete Guide to Linux System Administration 10
Entering Commands
• Features designed to simplify process of entering commands:– Tab completion
• Enter part of file or directory name
• Press tab key
• Shell fills in remainder of name
– Command history• Records each command
![Page 11: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/11.jpg)
The Complete Guide to Linux System Administration 11
Entering Commands (continued)
• Command history– Quickly call up and repeat any command from list – Press the up arrow key at command prompt– Press enter to execute command
• History command – Displays entire history list
• Bang– !
![Page 12: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/12.jpg)
The Complete Guide to Linux System Administration 12
Entering Commands (continued)
• Locate previously executed command– Use history number– Use beginning of command– Search history list
![Page 13: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/13.jpg)
The Complete Guide to Linux System Administration 13
The Shell Start-up Process
• Scripts executed when you log in to Linux– Initialize various parts of environment
• Script /etc/profile executed on first log in
• Contains configuration information that applies to every user on system
• Profile script– Found in user’s home directory– Specific to single user
![Page 14: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/14.jpg)
The Complete Guide to Linux System Administration 14
The Shell Start-up Process (continued)
• Some systems – Additional scripts are executed when user logs in
• When user starts shell– Additional scripts executed
• bashrc script – Executed each time user starts bash shell– User can add configuration information
![Page 15: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/15.jpg)
The Complete Guide to Linux System Administration 15
The Shell Start-up Process (continued)
![Page 16: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/16.jpg)
The Complete Guide to Linux System Administration 16
Using Aliases
• Alias – String substituted for another string at shell prompt
• Alias command – Define how shell will substitute one string for
another – Format:
• alias <string entered by user>=<string substituted by the shell>
– Enter without arguments to see list of current aliases
![Page 17: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/17.jpg)
The Complete Guide to Linux System Administration 17
Command-line Expansion
• Shell can make many different substitutions, including:– Aliases– Variables– Command substitution– Special characters
• Place commands in single quotes – Executed first by shell
![Page 18: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/18.jpg)
The Complete Guide to Linux System Administration 18
Command-line Expansion (continued)
• Special characters– Place in single quotes– Precede with $
• Example: $’\n’
– Other special characters:• ;
• *
• ?
![Page 19: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/19.jpg)
The Complete Guide to Linux System Administration 19
Command-line Expansion (continued)
• Avoid command-line expansion– Escape individual characters
• Using \
– Single quote– Double quote
![Page 20: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/20.jpg)
The Complete Guide to Linux System Administration 20
Shell Variables
• Shell variable– Name that can have value assigned to it– Can be number or string of text– Typically created using all uppercase letters
• Environment variable – Typically defined during initialization of operating
system or user’s shell– Can be accessed by any program
![Page 21: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/21.jpg)
The Complete Guide to Linux System Administration 21
Shell Variables (continued)
• env command – Start program with environment variable setting
that is not part of current environment– Only used for started program
• Set command– Displays list of all environment variables
• Echo command– View value of single environment variable
![Page 22: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/22.jpg)
The Complete Guide to Linux System Administration 22
Shell Variables (continued)
• Export command – Makes newly created environment variable
available to other programs
• PATH environment variable – Contains list of directories that shell searches
each time command is executed
• PS1 environment variable– Defines shell prompt for bash
![Page 23: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/23.jpg)
The Complete Guide to Linux System Administration 23
Data Redirection
• Standard input channel– STDIN– Keyboard
• Standard output channel– STDOUT– Monitor
• Standard error– STDERR
![Page 24: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/24.jpg)
The Complete Guide to Linux System Administration 24
Data Redirection (continued)
• Data can be redirected from standard channels
• Pipe– Connects output channel of one command to the
input channel of another command– Example: $ ls /etc | sort
![Page 25: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/25.jpg)
The Complete Guide to Linux System Administration 25
Data Redirection (continued)
![Page 26: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/26.jpg)
The Complete Guide to Linux System Administration 26
Data Redirection (continued)
• Mail command – Basic e-mail client – Use from command line to create e-mail message– Format: mail -s "subject line" e-mail_address
![Page 27: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/27.jpg)
The Complete Guide to Linux System Administration 27
Editing Text with vi• Text editor
– Single most important utility for system administrator
• Many different text editors are available for Linux
• Text-mode editors:– vi– emacs– pico– Joe
![Page 28: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/28.jpg)
The Complete Guide to Linux System Administration 28
Editing Text with vi (continued)
• Very powerful program
• Available on virtually every Linux system
• Not easy to use
• Must learn to use at least basic features in order to work as Linux system administrator– Memorize keystroke sequences– Work without any onscreen prompts
![Page 29: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/29.jpg)
The Complete Guide to Linux System Administration 29
Editing Text with vi (continued)
• To start:– vi command– Can be followed by name of file to edit
• Modal editor– Keystrokes are interpreted differently depending
on mode you are working in
![Page 30: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/30.jpg)
The Complete Guide to Linux System Administration 30
Editing Text with vi (continued)
• Modes:– Command mode– Insert mode– Replace mode
• Begin in command mode– Return to command mode by pressing Esc key
![Page 31: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/31.jpg)
The Complete Guide to Linux System Administration 31
Editing Text with vi (continued)
![Page 32: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/32.jpg)
The Complete Guide to Linux System Administration 32
Editing Text with vi (continued)
![Page 33: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/33.jpg)
The Complete Guide to Linux System Administration 33
Editing Text with vi (continued)
![Page 34: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/34.jpg)
The Complete Guide to Linux System Administration 34
Editing Text with vi (continued)
![Page 35: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/35.jpg)
The Complete Guide to Linux System Administration 35
Printing from the Command Line
• Quickly configure printer attached to parallel port
• Print files directly from command line
![Page 36: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/36.jpg)
The Complete Guide to Linux System Administration 36
Setting Up a Printer
• Print queue – Printer definition– Associate physical printer with named printer
definition
• Set up printer via GNOME desktop interface – Choose system settings– Print– Follow steps in dialog
![Page 37: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/37.jpg)
The Complete Guide to Linux System Administration 37
Printing From a Command Line
• lpr command– Print from command line– Uses series of filters based on type of file to print
• lpoptions command– Save commonly used list of options
![Page 38: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/38.jpg)
The Complete Guide to Linux System Administration 38
Summary
• Shell – Command interpreter used to start programs– Many shells are available
• Tab completion – Helps to quickly enter long file and directory
names
• Command history – Quickly reenter previously entered command
![Page 39: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/39.jpg)
The Complete Guide to Linux System Administration 39
Summary (continued)
• Scripts executed when:– User logs in– New shell opened
• Aliases– Shell replaces text on command-line entry with
different text
• Shell expands text on command line in several ways
![Page 40: The Complete Guide for Linux System Administration CH03 powerpoint](https://reader034.fdocuments.in/reader034/viewer/2022042623/546b4b12b4af9f612c8b4b29/html5/thumbnails/40.jpg)
The Complete Guide to Linux System Administration 40
Summary (continued)
• Environment variables store values that programs can access
• Flow of data between programs can be changed using redirection operators on command line
• Linux supports numerous text editors
• After setting up printer, print files from command line using lpr command