Upload
dhananjay-singh
View
222
Download
0
Embed Size (px)
DESCRIPTION
important
Citation preview
12/14/2014 Frequently used UNIX commands
http://wwwd0.fnal.gov/d0unix/archive/simple_commands.html 1/4
Frequently used UNIX commandsSome frequently used UNIX commands to manage directories, files etc. and simple utilties are summarized here. To get more descriptivehelp on using UNIX commands you can go to UNIX Commands.
Managing Directories
pwd show the current working directory cd xyz change working directory to xyz mkdir xyz create directory named xyz rmdir xyz remove/delete directory named xyz
Directory Identifiers
~(tilde) your home directory .(dot) the current working directory .. the parent directory (one level up) / root directory
Managing Files
ls list files in the working directory ls file1 list file file1 if it exists in the working directory ls dir1 list contents of the directory dir1 ls ‐l list directory contents with addtional information (long listing) ls ‐a list all files including hidden ones (.* files) cat file1 display contents of file1 more file1 display contents of file1, one page at a time head ‐n file1 display first n lines (default=10) of file1 tail ‐n file1 display last n lines (default=10) of file1 rm file1 remove/delete file1 rm ‐i file1 remove/delete file1 but inquire for confirmation cp file1 file2 copy file1 to file2
12/14/2014 Frequently used UNIX commands
http://wwwd0.fnal.gov/d0unix/archive/simple_commands.html 2/4
cp file1 dir1 copy file1 into directory dir1 mv file1 file2 move file1 to file2 (i.e., rename file1 to file2) mv file1 dir1 move file1 into directory dir1 diff file1 file2 display lines which are different in file1 and file2
For more descriptive help on searching, sorting etc., go to File Manipulation Utilities.
Managing Jobs ctrl‐c kill current job ctrl‐z suspend current job bg run suspended job in background fg bring suspended/background job to foreground ps list processes by their process identifier (PID) kill PID kill process with process identifier PID jobs list your jobs by job number
Online help man command display manual entry for command man ‐k keyword list manual pages that pertain to keyword insight on‐line help on SGI (X version) learn on‐line tutorial on IBM
System Information who list users logged onto the system whoami displays your logon ID (username) df display number of free blcoks on disk du display disk usage
Utility Programs wc file1 displays the number of lines, words and characters in file1 sort file1 sort contents of file, send results to standard output grep pattern file1 look for pattern in file1, send
12/14/2014 Frequently used UNIX commands
http://wwwd0.fnal.gov/d0unix/archive/simple_commands.html 3/4
results to standard output tar file1 write to or retrieve file1 from an archival storage medium (e.g., tape) compress file1 compresses file1 and writes file1.Z uncompress file1.Z restores file1 from compressed format uniq file1 file2 delete duplicate lines in file1 and write the new version of file1 into file2 find path ‐name \search the directory tree path file ‐print /for file and display echo string translate parameter string and display
Special Characters * match any character (wild card) & put job in background ! repeat previous command ; Concatenate several commands on one line # start of a comment #! first two characters of a shell script
I/O Redirection Commands (csh, tcsh) < redirect standard input (get input from) > redirect standard output (write output to) >& redirect standard output and standard error >! redirect standard output, overwrite file if it exists >!& redirect standard output and error, overwrite file if it exists | send output from first command to input of second command (pipe) >> append standard output >>& append standard output and error
Links to other D0 pagesTop of this document.D0 UNIX PageD0 home Page