1 / 36

Chapter 6

Chapter 6. Using the Shell and Text Files. Objectives. In this chapter, you will: Describe how a Linux shell operates Customize your shell environment Use common text editors to create or modify text files Describe popular text-processing methods and tools used on Linux.

aduck
Download Presentation

Chapter 6

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 6 Using the Shell and Text Files Guide to Linux Installation and Administration, 2e

  2. Objectives In this chapter, you will: • Describe how a Linux shell operates • Customize your shell environment • Use common text editors to create or modify text files • Describe popular text-processing methods and tools used on Linux Guide to Linux Installation and Administration, 2e

  3. Valued Gateway Client: Understanding the Shell • Command interpreter: program that accepts input from the keyboard and launches commands or otherwise controls the computer system • Linux command interpreter is called the shell • The shell is only loaded when a user logs in at a text mode login prompt • Different types of shells are available for Linux Guide to Linux Installation and Administration, 2e

  4. Valued Gateway Client: The Shell Prompt • Shell prompt: set of words or characters indicating that the shell is ready for commands • The default shell prompt includes four components: • The user account name • The hostname • The last part of the full directory path • A prompt character Guide to Linux Installation and Administration, 2e

  5. A Standard Shell Prompt Guide to Linux Installation and Administration, 2e

  6. Valued Gateway Client: The Functions of a Shell • A shell’s primary purpose is to launch programs • A Linux shell gives users the ability to write scripts that the shell can execute • The shell has many built-in features to work with files and commands on a Linux system Guide to Linux Installation and Administration, 2e

  7. Different Types of Shells Guide to Linux Installation and Administration, 2e

  8. Different Types of Shells Guide to Linux Installation and Administration, 2e

  9. Valued Gateway Client: Entering Commands • Modern shells include features designed to simplify the process of entering commands and command parameters: • Tab completion • History feature Guide to Linux Installation and Administration, 2e

  10. Valued Gateway Client: Using Tab Completion • Tab completion is a shell feature that lets you enter part of a file or directory name, press the Tab key, and have the shell fill in the remainder of the name • Using tab completion makes it easier to enter long or complex directory paths and filenames Guide to Linux Installation and Administration, 2e

  11. Valued Gateway Client: Using the History Feature • Command history: records each command that you enter at the shell prompt • History list: recently entered commands • To locate a previously executed command • Use the history number • Use the beginning of a command • Search the history list Guide to Linux Installation and Administration, 2e

  12. Valued Gateway Client: The Shell Start-up Process • The profile scripts are executed when a user logs into a Linux system • Additional scripts are executed when a user starts a shell • The /etc/profile script contains configuration information that applies to every user on the system Guide to Linux Installation and Administration, 2e

  13. A Typical Start-up Script Guide to Linux Installation and Administration, 2e

  14. Valued Gateway Client: Customizing the Shell • You can customize the Linux environment with the following methods: • Use aliases • Use symbolic links • Use environment variables Guide to Linux Installation and Administration, 2e

  15. Valued Gateway Client: Using Aliases • Alias: string of characters that is substituted for another string of characters at the shell prompt • The alias command lets you define an alias for text you enter at a shell prompt • General format of the alias command: alias<string entered>=<string substituted by the shell> Guide to Linux Installation and Administration, 2e

  16. Valued Gateway Client: Symbolic Links • Symbolic link • File that refers to another file or directory, rather than containing data itself • Used when the same data must be accessed from two locations in the directory structure, or by two different names • Commonly used in directories such as /lib and /usr/lib • To create a symbolic link, use the ln command with the -s option Guide to Linux Installation and Administration, 2e

  17. A Symbolic Link Guide to Linux Installation and Administration, 2e

  18. Viewing a Symbolic Link Guide to Linux Installation and Administration, 2e

  19. Valued Gateway Client: Environment Variables • Environment variables are settings, or values, available to any program launched by a user • Each environment variable is assigned a value • Set command: displays a list of all environment variables defined in your current environment • To see the value of an environment variable, execute echo followed by the environment variable name preceded by a dollar sign • The export command makes an environment variable available to other programs launched from that environment Guide to Linux Installation and Administration, 2e

  20. Valued Gateway Client: Using Text Editors • Linux supports numerous text editors • Linux system administrator can modify configuration files using any text editor • Files that use a markup language can be created in any text editor • You can filter text files within some text editors Guide to Linux Installation and Administration, 2e

  21. Valued Gateway Client: The Variety of Linux Text Editors • Graphical text editors are included on modern Linux desktops, such as • gedit in Gnome • kedit and kate in KDE • Widely used text-mode editors: • vi • emacs • pico • joe Guide to Linux Installation and Administration, 2e

  22. The pico Text Editor Guide to Linux Installation and Administration, 2e

  23. Valued Gateway Client: Using the vi Editor • vi is a modal editor – keystrokes are interpreted differently depending on the mode you are working in • vi has several modes: • Command mode • Insert mode • Replace mode Guide to Linux Installation and Administration, 2e

  24. Using the vi Editor Guide to Linux Installation and Administration, 2e

  25. vi Commands to Enter Insert or Replace Mode Guide to Linux Installation and Administration, 2e

  26. Additional vi Commands Guide to Linux Installation and Administration, 2e

  27. Valued Gateway Client: Text Processing • There are two methods to create formatted documents: • Graphical, or WYSIWYG (what-you-see-is-what-you-get) • Rely on markup languages to define special codes that format documents Guide to Linux Installation and Administration, 2e

  28. Valued Gateway Client: Markup Languages • Widely used markup languages in the Unix and Linux world: • HTML (hypertext markup language) • TeX – a document-processing system with two popular versions: LaTeX and TeTeX • roff codes for online documents Guide to Linux Installation and Administration, 2e

  29. An HTML Document in vi Guide to Linux Installation and Administration, 2e

  30. Valued Gateway Client: Controlling Fonts • The X Window System is installed with many different fonts • xfontsel graphical program is used to review and select fonts • Both Gnome and KDE provide a standard font selection dialog box • Fonts are managed in X using the xfs font server • New fonts can be added to the Linux system any time Guide to Linux Installation and Administration, 2e

  31. The xfontsel Program Guide to Linux Installation and Administration, 2e

  32. The Font Selector Dialog Box in Gnome Guide to Linux Installation and Administration, 2e

  33. Valued Gateway Client: Manipulating Text Files • Filtering is the process of adding, removing, or altering data in the text file based on complex rules or patterns • sort command: sorts all of the lines in a text file, writing them out in alphabetical order • sed command: processes each line in a text file according to a series of command-line options • awk and perl programming languages can be used to create scripts for filtering text files Guide to Linux Installation and Administration, 2e

  34. Linux Text-filtering Commands Guide to Linux Installation and Administration, 2e

  35. Summary • Linux shell: program that launches other programs and works with files in Linux • Modern shells include features designed to simplify the process of entering commands - tab completion and history • Aliases within a shell cause the shell to replace text on a command-line entry with different text before trying to execute the command • Environment variables store values that any program can access Guide to Linux Installation and Administration, 2e

  36. Summary • Linux supports text editors, such as vi • Linux programs format text using a WYSIWYG display or markup languages such as LaTeX and roff use codes • Fonts are managed in X Windows System using a font server • Gnome and KDE provide a dialog box to select the font for graphical programs • Filtering text files can be done within some text editors or using different command-line utilities Guide to Linux Installation and Administration, 2e

More Related