SUSE Linux Enterprise Desktop Administration - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

SUSE Linux Enterprise Desktop Administration

Description:

In this exercise, use the history feature of the shell ... Typing i (insert) Pressing the Insert key. Press Esc once to take you back to command mode ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 38
Provided by: facult9
Category:

less

Transcript and Presenter's Notes

Title: SUSE Linux Enterprise Desktop Administration


1
SUSE Linux Enterprise Desktop Administration
  • Chapter 8
  • Work with the Linux Shell and Command Line

2
Objectives
  • Objective 1Get to Know the bash Shell
  • Objective 2Get to Know Common Command-Line Tasks
  • Objective 3Understand Command Syntax and Special
    Characters
  • Objective 4Get to Know Linux Text Editors

3
Objective 1Get to Know the bash Shell
  • Shell
  • Accepts a users entries, interprets them,
    converts them to system calls, and delivers
    system messages back to the user, making it a
    command interpreter
  • To understand the bash shell, you need to know
    the following
  • Types of Shells
  • bash Configuration Files
  • Completion of Commands and Filenames
  • History Function

4
Types of Shells
  • Examples of some popular shells
  • The Bourne Shell (/bin/sh symbolic link to
    /bin/bash)
  • The Bourne Again Shell (/bin/bash)
  • The Korn shell (/bin/ksh)
  • The C shell (/bin/csh symbolic link to
    /bin/tcsh)
  • The TC shell (/bin/tcsh)
  • Shells differ in the functionality they provide
  • Every shell can be started like a program
  • You can switch at any time to a different shell

5
Types of Shells (continued)
  • The shell does not terminate on its own
  • You need to enter the exit command to return to
    the previous shell
  • Login shell
  • A shell is started at a text console right after
    a user logs in
  • Which shell is started for which user is defined
    in the user database
  • The standard Linux shell is bash

6
bash Configuration Files
  • Login shells
  • Started whenever a user logs in to the system or
    a user logs in through an X display manager
  • The following files are read when starting a
    login shell
  • /etc/profile
  • /etc/bash.bashrc
  • For your own systemwide bash configurations, use
    the file /etc/bash.bashrc.local
  • /.bashrc
  • Configuration file in which users store their
    customizations

7
bash Configuration Files (continued)
  • Nonlogin shells
  • The following files are read when starting a
    nonlogin shell
  • /etc/bash.bashrc
  • /etc/bash.bashrc.local
  • /.bashrc
  • SLED has a default setup that ensures users do
    not see any difference between both types of
    shell
  • To read in a changed configuration file and to
    apply the changes to the current session
  • Use the internal shell source command

8
Completion of Commands and Filenames
  • The bash shell supports a function of completing
    commands and filenames
  • Just enter the first characters of a command (or
    a filename) and press Tab
  • If more than one possibility exists
  • The bash shell shows all possibilities when you
    press Tab a second time

9
History Function
  • bash stores the commands you enter so you have
    easy access to them again when needed later
  • By default, the commands are written in the
    .bash_history file in the users home directory
  • You can display the content of the file by using
    the history command
  • You can display the commands stored in the
    history cache (one at a time) by using the arrow
    keys
  • Enter part of the command and press Ctrlr
  • To search the history list for matching commands
    and display them

10
Objective 2Get to Know Common Command-Line Tasks
  • Two features make working with the bash shell
    more powerful
  • Variables
  • Aliases

11
Variables
  • Environment variables
  • Control the behavior of a program that is started
    from a shell
  • Shell variables
  • Control the behavior of the shell itself
  • Some important environment variables include the
    following
  • PATH
  • HOME
  • USER

12
Variables (continued)
  • To display the value of a shell or environment
    variable, enter echo variable
  • To set the value of a variable or to create a new
    variable, use the syntax variablevalue

13
Aliases
  • Allow you to create shortcuts for commands and
    their options
  • Or to create commands with entirely different
    names
  • You can find out about the aliases defined on
    your system with the alias command
  • To see whether a given command is an alias for
    something else, use the type command

14
Aliases (continued)
  • Most of the aliases used on a systemwide basis
    are defined in the file /etc/bash.bashrc
  • Aliases are defined with the alias command and
    can be removed with the unalias command
  • Syntax for defining aliases
  • alias aliasnamecommand options
  • An alias defined in this way is only valid for
    the current shell
  • To make an alias persistent, you need to store
    the definition in one of the shells
    configuration files

15
Exercise 8-1 Execute Commands at the Command Line
  • In this exercise, use the history feature of the
    shell
  • Then create an alias labeled hello that prints a
    personal welcome message, Hello username, on the
    screen
  • Finally, remove this alias

16
Objective 3Understand Command Syntax and Special
Characters
  • You can use specific characters to provide
    special functionality
  • In this objective, you learn about the following
  • Select Your Character Encoding
  • Name Expansion Using Search Patterns
  • Prevent the Shell from Interpreting Special
    Characters

17
Select Your Character Encoding
  • Variables are used to determine the localization
  • Use the locale command to get a list of the
    localization variables

18
Select Your Character Encoding (continued)
  • The variable LANG specifies the language
  • SUSE Linux Enterprise Desktop uses UTF-8 encoding
    for all users, except the user root
  • The output of some commands depends on the type
    of encoding

19
Name Expansion Using Search Patterns
  • Occasionally, you might want to perform
    operations on a series of files without having to
    name all the files
  • In this case, you could make use of the search
    patterns shown in Table 8-1
  • If search patterns (wildcards) are given on the
    command line
  • The shell tries to compare these with the
    filenames in the file system and, if they match,
    the expression is replaced with all the filenames
    found

20
Name Expansion Using Search Patterns (continued)
Table 8-1 Search patterns
21
Prevent the Shell from Interpreting Special
Characters
  • To prevent the shell from interpreting special
    characters in the command line
  • They must be masked by using the following
  • \

22
Exercise 8-2 Work with Command Syntax and
Special Characters
  • In this exercise, you learn how to use wildcards
    and other special characters
  • Change the character encoding from UTF-8 to POSIX
  • Then, list all filenames in the /bin directory
    that
  • Start with the character a
  • Consist of four characters
  • Consist of four or more characters
  • Do not start with any of the characters from a to
    r

23
Exercise 8-2 Work with Command Syntax and
Special Characters (continued)
  • In the next part of this exercise, use the
    Nautilus file manager to create new files named
    My, File, and My File
  • Then, list the files and remove them
  • To do this, you have to mask special characters

24
Objective 4Get to Know Linux Text Editors
  • Several text editors are available in Linux,
    including
  • vi
  • emacs
  • xemacs
  • xedit
  • gedit
  • kwrite
  • Two types of editors exist
  • Graphical editors
  • Command-line editors

25
Work with gedit (Graphical Editor)
  • The gedit editor can be started from the main
    menu (Computer gt More Applications gt Tools gt
    gedit)
  • See Figure 8-1

26
Figure 8-1 The gedit editor
27
Work with vi (Command-Line Editor)
  • The advantage of command-line editors
  • You can use them without having a graphical
    desktop environment installed
  • vi is used by most administrators because it is
    available on every Linux and UNIX system
  • Always available, even on the rescue system
  • In SUSE Linux Enterprise Desktop, vim (vi
    improved) by Bram Moolenaar is the standard vi
    editor

28
Start vi
  • You can start vi by entering vi or vim in a
    terminal window
  • See Figure 8-2

29
Figure 8-1 The vi editor
30
Use the Editor vi
  • You can move the cursor
  • With the k, j, h, and l keys (kone line up,
    jone line down, hto the left, lto the right)
  • By using the arrow keys (Up-arrow, Down-arrow,
    Left-arrow, Right-arrow)

31
Learn the Working Modes
  • vi is mode-oriented
  • When vi is first started, it is in command mode
  • Anything you enter is considered a command
  • To enter text, you must first switch the editor
    to insert mode by
  • Typing i (insert)
  • Pressing the Insert key
  • Press Esc once to take you back to command mode
  • From command mode, you can switch to command-line
    mode by entering

32
Learn the Working Modes (continued)
  • Available modes
  • Command mode
  • Insert mode
  • Command-line mode

33
Learn the Working Modes (continued)
Table 8-2 Commands in the vi command mode
34
Learn the Working Modes (continued)
Table 8-3 Commands in the vi command-line mode
35
Exercise 8-3 Use vi to Edit Files in the Linux
System
  • In this exercise, create a new vi_test file with
    the text editor vi
  • Then, edit the text in the command mode of vi

36
Summary
  • After logging in to a Linux system, a login shell
    is started
  • Although there are many shells available for use
    in Linux, the default shell is the Bourne Again
    Shell (bash)
  • The bash shell is case-sensitive
  • Several environment variables are loaded when a
    shell is started that is used by programs to set
    the user environment and locale
  • Aliases are special shell variables that contain
    commands

37
Summary (continued)
  • Wildcards are special characters that can be used
    to represent patterns when specifying file or
    directory names on the file system
  • Although many text-based and graphical text
    editors are available for Linux systems, the vi
    editor is the most commonly used editor across
    different distributions of Linux and versions of
    UNIX
Write a Comment
User Comments (0)
About PowerShow.com