Presentation is loading. Please wait.

Presentation is loading. Please wait.

LPI Linux Certification

Similar presentations


Presentation on theme: "LPI Linux Certification"— Presentation transcript:

1 LPI Linux Certification
Chapter 1 GNU and Unix Commands

2 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

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

4 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.

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

6 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.

7 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

8 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.

9 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.

10 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.

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

12 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.

13 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.

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

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

16 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.

17 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

18 Management Commands CP MKDIR MV RM RMDIR TOUCH

19 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

20 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

21 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.

22 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.

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

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

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

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

27 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.

28 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 .

29 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

30 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.

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

32 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.

33 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

34 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.

35 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.

36 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 , this means kill using the sigterm signal 15 the process

37 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.

38 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

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

40 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.

41 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.

42 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

43 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

44 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 .


Download ppt "LPI Linux Certification"

Similar presentations


Ads by Google