LPI Linux Certification

Slides:



Advertisements
Similar presentations
CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
Advertisements

A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 4: More Command Line Interface (CLI) Chapter 7: The Linux Shell By Fred R. McClurg Linux.
1 © 2001 John Urrutia. All rights reserved. Chapter 5 The Shell Overview.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Unix Talk #2 (sed). 2 You have learned…  Regular expressions, grep, & egrep  grep & egrep are tools used to search for text in a file  AWK -- powerful.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 8 Shell.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Linux+ Guide to Linux Certification, Third Edition
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
Chapter Four I/O Redirection1 System Programming Shell Operators.
UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.
40 Years and Still Rocking the Terminal!
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
CS252: Systems Programming Ninghui Li Slides by Prof. Gustavo Rodriguez-Rivera Topic 7: Unix Tools and Shell Scripts.
Manipulating Files Refresher. The touch Command touch is used to create a new, empty file. If the file already exists, touch updates the time and date.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
Chapter 5: The Shell The Man in the Middle. In this chapter … The command line Input, output, and redirection Process management Wildcards and expansion.
Linux+ Guide to Linux Certification, Second Edition
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Linux Administration Working with the BASH Shell.
Introduction to the bash Shell (Bourne-Again SHell)
Lesson 5-Exploring Utilities
Introduction to Shells
Chapter 11 Command-Line Master Class
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Shell Features CSCI N321 – System and Network Administration
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Part 1: Basic Commands/Utilities
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
CSE 374 Programming Concepts & Tools
CSE 303 Concepts and Tools for Software Development
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Introduction to Linux Week 0 - Thursday.
Unix Talk #2 (sed).
Chapter Four UNIX File Processing.
Linux Shell Script Programming
Module 6 Working with Files and Directories
Presentation transcript:

LPI Linux Certification Chapter 1 GNU and Unix Commands

Objectives Understanding and use of the Command Line Use of Text Streams and Processing Filters Basic File Management Using Streams , Pipes and redirects Create, change and kill processes Change the Priority of a process Using regular expressions

The Command line System interface is the Shell on Linux it's Bash Shell = Command interpertur.

Shell Variable Basics PS1 contains the system prompt Uses echo to display value of any shell variable Example : echo $PS1 PATH The path variable contains information used by the shell to find and launch programs or commands.

Shell Basics Export To make a variable available to the system use the export command Example : $ export Javapath

Entering commands Commands consist of 4 general components A valid command(shell or program or script) found along the PATH of directories listed in the PATH variable Command options Argument , such as file names Line acceptance , the enter key.

Entering multiple commands Commands can be entered interactively by using the programming feature of the shell Multiple command can also be entered on the same line separated by a semicolon. Example : $ls;ps

Command History and Editing You can use command history to recall recent typed commands. The size of the history is controlled by the HISTFILE shell variable. Set by default to 500 lines . You can adjust this by adjusting HISTFILE. Use the history command to view the history file.

History expanders !! most recent command !n refers to command “n” from the history ! -n current command minus n from history ! string most recent command starting with string !? String most recent command containing string ^ string1^string2 Substitution of string one for string two.

History editing Control- P or Up Arrow , gives previous . Control-n or Down Arrow , next . Control-b or Left , one char left. Control-f or Right , one char right. Control-a , beginning of line . Control-e , end of line Additional command on page 18 of text.

Processing Text Streams Using Text Processing Filters cut,expand, fmt,head,join, nl,od,paste,pr, split,tac, tail,tr,wc, Xargs.

Some commonly used Text-Filters head : prints the first few lines of a file or files Syntax: head [options] [files] Tail : prints the last few lines of a file. Example : tail -f /var/log/messages This would allow you to see entries into the log files as the were occurring. The -f switch means follow.

Sed or Stream editor Is intended as a text filter Can be called from the command line or from a file Uses regular expressions Useful in doing substitution or removals of know text from a file or groups of files.

Preform Basic File Management File system Objects Directories and files Inodes Commands

File System Objects File system is shaped like a Tree It consist of object that contain other objects

Directories and Files Directories are objects intended to contain other objects Files are objects intended to contain information The top of the directory is called the root it is represented by the “/” All other objects can be referenced by there relationship to “root” in tree like manner.

Inodes Inodes are the objects that hold the identification information about object in the tree. Such as location on the disk , modification time and security settings. Each ext2 file system is created with a finite number of inodes

Management Commands CP MKDIR MV RM RMDIR TOUCH

Copy (cp) cp [options] file1 file2 -f force overwrite -i prompt interactively before proceeding -p Preserve all file attributes such as ownership and permissions as well as time stamp -r -R recursively copy directories -v Display the name before copying

Make Directory (mkdir) mkdir [options] directories Make one or more directories , you must have write permissions in the directory your trying to create more directories in. -m set the access mode for directory -p Create parent directory if needed ~ , is used as a short cut to user home directory

Move (mv) Move or rename files and directories mv [options] source target -f Force the move even if target exist, suppressing warning messages -i Query interactively before moving file.

Remove (rm) Delete one or more files rm [ options ] files To remove a file you must have write permission in the directory that holds the file. -d removes directory that are not empty -f Force removal with out prompting -i interactive mode -r, -R if file is directory recursively remove all contents.

Remove Dir (rmdir) rmdir [options] directories Delete directories that must be empty -p Remove any intervening parent directories that become empty as a result.

Touch touch [options] files -a Change only the access time -m change only modification time -t timestamps

Wildcards * ? [characters] [!characters] [a-z] [!a-z] {frag1,frag2,frag3...}

Using Unix Streams,Pipes, and Redirects Standard I/O and default file descriptors Pipes Redirection

Standard I/O Standard input ( stdin) default is keyboard also known as file descriptor 0. Standard output (stdout) default is the screen also known as file descriptor 1. Standard error (stderr) default is also the screen also known as file descriptor 2. All three streams may be redirected at will.

Pipes Pipes take output from one program and “Pipe it into another program , thus standard output from a program can become standard input to another By chaining the output of one command to the input of another command you can produce some very powerful applications .

Redirection Use redirection to send standard output to another place like a file. Shell redirecting operators are: > , >> , < and | See table 1-10 for useful Standard I/O redirection operator syntax

Tee Read from standard input and write to both standard output and one or more files. tee [ options] files -a Append to files rather than overwrite.

Create, Monitor and Kill Processes What are processes Process monitoring Signaling Active Processes Terminating Processes Shell Job Control

What are Processes Every command or program executed on your operating system is a process Each has these quality's A lifetime , process ID , user and group ID, parent process ID, environment and current working directory.

Process Monitoring ps [options] Generates a one time snapshot of current processes. The most common form is ps -aux See manual for all the options , man ps. pstree [options] [pid|user] Shows a tree representation of the processes , similar to using ps -f

Top top [command -line options] Produces a continually updated display of all processes . Has an interactive mode allowing you to enter commands such as kill . Displays most of the same information as ps does.

Signaling Active Processes All processes listen for signals . Signals are numeric integer messages Most common used signals are: HUP,INT,KILL,TERM,TSTP. Each have a corresponding number 1,2,9,15,and 18 respectively. To see all the signal on your machine type {kill -l} for a list.

Kill Kill is used to stop a process or series of processes. Kill [-s sigspec | -sigspec] [pids] See examples in the book Use ps or top to identify the process ID and then use the kill command to kill it . Kill -15 1001 , this means kill using the sigterm signal 15 the process 1001 .

Shell Job Control Allows you to place executing programs in the background and bring them into the foreground The shell command $ netscape & place the netscape program in the background , it returns a job number and a PID number. Use the bg , fg and jobs commands to control background jobs.

Modify Process Execution Priorities Be nice use nice and renice Nice , assigns a priority number for program execution at the time it is executed. Renice is used to change the priority of a running program. Nice numbers range from -20 to +19 the lower the number the higher it's priority Only root can lower a nice number All user processes start at zero (0) See the book for syntax instruction

Making use of Regular Expressions Regular expression syntax Using grep Using sed Quoting

What are Regular expressions Regular Expressions are strings used in matching operations . The values inside the regular expression is used to search for or match a string. Regular expressions make extensive use of place holders and wildcards , as well as reserve symbols to represent actions and values.

Regular expression syntax Methacharacters , Characters that take on special meaning . ^ the beginning of a line or $ end of a line. See table 1-12 , 1-13,and 1-14 for a expanded list Literals everything not a Methacharacter. Position Anchors , such as ^ or $. Character sets , used to match text Modifiers , change the meaning of other characters in the expression.

Grep Syntax : grep [options] regex [files] Grep evolved from a line editor (ed) command into a utility of it's own. Used to search files or standard input for lines containing a match of the regular expression

Grep Options -c Display only a count of the lines that match -h Display matched lines -i ignore case -n display match lines with line numbers -v print all lines that do not match the regexp

Quoting To use Regular expression on the command line with grep and sed you must escape those Metacharacters you don't want the shell to expand. The backslash \ is used \* Single quotes '*' Double quotes “*” All stop the shell from expanding them .