1 / 41

Chapter 3: Using the Shell

The Complete Guide to Linux System Administration. 2. Objectives. Use common features of the shell to work at the command lineManipulate variables in the shell to control your working environmentRedirect data at the command lineEdit text using the vi editorPrint basic files from the command line

bing
Download Presentation

Chapter 3: Using the Shell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Chapter 3: Using the Shell The Complete Guide to Linux System Administration

    2. 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

    3. 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

    4. 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

    5. 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, #

    6. 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

    7. 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

    8. 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

    9. 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

    10. 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

    11. 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 !

    12. 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

    13. 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

    14. 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

    15. The Complete Guide to Linux System Administration 15 The Shell Start-up Process (continued)

    16. 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

    17. 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

    18. 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: ; * ?

    19. The Complete Guide to Linux System Administration 19 Command-line Expansion (continued) Avoid command-line expansion Escape individual characters Using \ Single quote Double quote

    20. 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

    21. 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

    22. 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

    23. The Complete Guide to Linux System Administration 23 Data Redirection Standard input channel STDIN Keyboard Standard output channel STDOUT Monitor Standard error STDERR

    24. 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

    25. The Complete Guide to Linux System Administration 25 Data Redirection (continued)

    26. 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

    27. 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

    28. 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

    29. 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

    30. 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

    31. The Complete Guide to Linux System Administration 31 Editing Text with vi (continued)

    32. The Complete Guide to Linux System Administration 32 Editing Text with vi (continued)

    33. The Complete Guide to Linux System Administration 33 Editing Text with vi (continued)

    34. The Complete Guide to Linux System Administration 34 Editing Text with vi (continued)

    35. The Complete Guide to Linux System Administration 35 Editing Text with vi (continued)

    36. The Complete Guide to Linux System Administration 36 Printing from the Command Line Quickly configure printer attached to parallel port Print files directly from command line

    37. The Complete Guide to Linux System Administration 37 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

    38. The Complete Guide to Linux System Administration 38 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

    39. The Complete Guide to Linux System Administration 39 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

    40. The Complete Guide to Linux System Administration 40 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

    41. The Complete Guide to Linux System Administration 41 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

More Related