chapter 1 gnu and unix commands
Download
Skip this Video
Download Presentation
LPI Linux Certification

Loading in 2 Seconds...

play fullscreen
1 / 44

LPI Linux Certification - PowerPoint PPT Presentation


  • 122 Views
  • Uploaded on

Chapter 1 GNU and Unix Commands. LPI Linux Certification. 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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' LPI Linux Certification' - quintessa-haley


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
objectives
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
The Command line
  • System interface is the Shell on Linux it\'s Bash
  • Shell = Command interpertur.
shell variable basics
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
Shell Basics
  • Export
  • To make a variable available to the system use the export command
  • Example : $ export Javapath
entering commands
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
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
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
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
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
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
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
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
Preform Basic File Management
  • File system Objects
  • Directories and files
  • Inodes
  • Commands
file system objects
File System Objects
  • File system is shaped like a Tree
  • It consist of object that contain other objects
directories and files
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
  • 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
Management Commands
  • CP
  • MKDIR
  • MV
  • RM
  • RMDIR
  • TOUCH
copy cp
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
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 (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
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
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
  • touch [options] files
  • -a Change only the access time
  • -m change only modification time
  • -t timestamps
wildcards
Wildcards
  • *
  • ?
  • [characters]
  • [!characters]
  • [a-z]
  • [!a-z]
  • {frag1,frag2,frag3...}
using unix streams pipes and redirects
Using Unix Streams,Pipes, and Redirects
  • Standard I/O and default file descriptors
  • Pipes
  • Redirection
standard i o
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
  • 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
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
slide30
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
Create, Monitor and Kill Processes
  • What are processes
  • Process monitoring
  • Signaling Active Processes
  • Terminating Processes
  • Shell Job Control
what are processes
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
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
slide34
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
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.
slide36
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
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
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
Making use of Regular Expressions
  • Regular Expression
  • Regular expression syntax
  • Using grep
  • Using sed
  • Quoting
what are regular expressions
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
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.
slide42
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
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
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 .
ad