Using the Shell and Text Files - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

Using the Shell and Text Files

Description:

General format of the alias command: alias string entered = string substituted by the shell ... Environment variables store values that any program can access ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 37
Provided by: jimb192
Category:
Tags: dollar | files | general | shell | store | text | using

less

Transcript and Presenter's Notes

Title: Using the Shell and Text Files


1
Chapter 6
  • Using the Shell and Text Files

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

3
Understanding the Shell
Valued Gateway Client
  • 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

4
The Shell Prompt
Valued Gateway Client
  • 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

5
A Standard Shell Prompt
6
The Functions of a Shell
Valued Gateway Client
  • A shells 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

7
Different Types of Shells
8
Different Types of Shells
9
Entering Commands
Valued Gateway Client
  • Modern shells include features designed to
    simplify the process of entering commands and
    command parameters
  • Tab completion
  • History feature

10
Using Tab Completion
Valued Gateway Client
  • 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

11
Using the History Feature
Valued Gateway Client
  • 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

12
The Shell Start-up Process
Valued Gateway Client
  • 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

13
A Typical Start-up Script
14
Customizing the Shell
Valued Gateway Client
  • You can customize the Linux environment with the
    following methods
  • Use aliases
  • Use symbolic links
  • Use environment variables

15
Using Aliases
Valued Gateway Client
  • 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
  • aliasltstring enteredgtltstring substituted by the
    shellgt

16
Symbolic Links
Valued Gateway Client
  • 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

17
A Symbolic Link
18
Viewing a Symbolic Link
19
Environment Variables
Valued Gateway Client
  • 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

20
Using Text Editors
Valued Gateway Client
  • 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

21
The Variety of Linux Text Editors
Valued Gateway Client
  • 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

22
The pico Text Editor
23
Using the vi Editor
Valued Gateway Client
  • 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

24
Using the vi Editor
25
vi Commands to Enter Insert or Replace Mode
26
Additional vi Commands
27
Text Processing
Valued Gateway Client
  • There are two methods to create formatted
    documents
  • Graphical, or WYSIWYG (what-you-see-is-what-you-ge
    t)
  • Rely on markup languages to define special codes
    that format documents

28
Markup Languages
Valued Gateway Client
  • 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

29
An HTML Document in vi
30
Controlling Fonts
Valued Gateway Client
  • 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

31
The xfontsel Program
32
The Font Selector Dialog Box in Gnome
33
Manipulating Text Files
Valued Gateway Client
  • 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

34
Linux Text-filtering Commands
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

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
Write a Comment
User Comments (0)
About PowerShow.com