SUSE Linux Enterprise Desktop Administration

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

Lecture 4 Shell environment III: - command alias & history; - job control; - editor (vim) CSE4251 The Unix Programming Environment 1.
A Guide to Unix Using Linux Fourth Edition
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Introduction to Shell Script Programming
Chapter 3 Mastering Editors
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
An Introduction to UNIX System --- Cosc513 Presentation n Instructor: Morteza Anvari n Author: Yonghong Pan n ID#: n Date: Jan.29, 2001.
Chapter 6: Shell Programming
CENT 305 Information Systems Security Linux Introduction.
An Introduction to Unix Shell Scripting
Shell Features CSCI N321 – System and Network Administration Copyright © 2000, 2005 by Scott Orr and the Trustees of Indiana University.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
SUSE Linux Enterprise Desktop Administration Chapter 2 Use the Linux Desktop.
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Third Edition
SUSE Linux Enterprise Desktop Administration Chapter 14 Customize the Graphical Interface on SUSE Linux Enterprise Desktop 10.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
SUSE Linux Enterprise Desktop Administration Chapter 6 Manage Software.
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.
Week 8: Linux / ubuntu Dr. I. H. Shah. / CSCS 301 Fall 2009.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
User Environments Objectives –to provide appropriate environments for different types of users Contents –different login programs –user profiles –restricted.
Chapter Six Introduction to Shell Script Programming.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop III - Part A Shell Commands Professional Training.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
Linux+ Guide to Linux Certification, Second Edition
Linux Administration Working with the BASH Shell.
 Prepared by: Eng. Maryam Adel Abdel-Hady
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Release Numbers MATLAB is updated regularly
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
California State University Fresno
Guide To UNIX Using Linux Third Edition
Linux System Administration Editors
Shell Environments.
Chapter 1 The Essence of UNIX and Linux
An Introduction to UNIX System --- Cosc513 Presentation
The Linux Command Line Chapter 24
SUSE Linux Enterprise Desktop Administration
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
SUSE Linux Enterprise Desktop Administration
Week 1 – Lesson 2: Creating Shell Scripts, Linux Commands
Linux Operations and Administration
Lab 7 Shell Script Reference:
A shell is a user interface.
The Linux Command Line Chapter 24
Presentation transcript:

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

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

Objective 1—Get to Know the bash Shell Accepts a user’s 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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 user’s 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 Ctrl+r To search the history list for matching commands and display them SUSE Linux Enterprise Desktop Administration

Objective 2—Get to Know Common Command-Line Tasks Two features make working with the bash shell more powerful: Variables Aliases SUSE Linux Enterprise Desktop Administration

Variables Environment variables Shell 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 SUSE Linux Enterprise Desktop Administration

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 variable=value SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 aliasname=‘‘command 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 shell’s configuration files SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

Objective 3—Understand 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 SUSE Linux Enterprise Desktop Administration

Select Your Character Encoding Variables are used to determine the localization Use the locale command to get a list of the localization variables SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

Name Expansion Using Search Patterns (continued) Table 8-1 Search patterns SUSE Linux Enterprise Desktop Administration

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: \ “…” ‘…’ SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

Objective 4—Get 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 SUSE Linux Enterprise Desktop Administration

Work with gedit (Graphical Editor) The gedit editor can be started from the main menu (Computer > More Applications > Tools > gedit) See Figure 8-1 SUSE Linux Enterprise Desktop Administration

SUSE Linux Enterprise Desktop Administration Figure 8-1 The gedit editor SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

Start vi You can start vi by entering vi or vim in a terminal window See Figure 8-2 SUSE Linux Enterprise Desktop Administration

SUSE Linux Enterprise Desktop Administration Figure 8-1 The vi editor SUSE Linux Enterprise Desktop Administration

Use the Editor vi You can move the cursor: With the k, j, h, and l keys (k–one line up, j–one line down, h–to the left, l–to the right) By using the arrow keys (Up-arrow, Down-arrow, Left-arrow, Right-arrow) SUSE Linux Enterprise Desktop Administration

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 ‘‘:’’ SUSE Linux Enterprise Desktop Administration

Learn the Working Modes (continued) Available modes Command mode Insert mode Command-line mode SUSE Linux Enterprise Desktop Administration

Learn the Working Modes (continued) Table 8-2 Commands in the vi command mode SUSE Linux Enterprise Desktop Administration

Learn the Working Modes (continued) Table 8-3 Commands in the vi command-line mode SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration

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 SUSE Linux Enterprise Desktop Administration