Unix Commands                                                   Unix                                                      ...
Arguments x Through y                                      :x-y      Standard Commands                               where...
Is this document clear? Is it missing crucial information?   Please mail comments to the handout editor, CAE, 1410 Enginee...
Upcoming SlideShare
Loading in...5



Published on

You can d

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Unix Commands Unix January 2003This quick reference lists commands, including a syntax diagram 2. Commandsand brief description. […] indicates an optional part of the 2.1. Command-line Special Characterscommand. For more detail, use: Quotes and Escape man command Join Words "…"Use man tcsh for the command language. Suppress Filename, Variable Substitution … Escape Character 1. Files Separation, Continuation1.1. Filename Substitution Command Separation ;Wild Cards ? * Command-Line Continuation (at end of line) Character Class (c is any single character) [c…] Range [c-c] 2.2. I/O Redirection and PipesHome Directory ~ Standard Output >Home Directory of Another User ~user (overwrite if exists) >!List Files in Current Directory ls [-l] Appending to Standard Output >>List Hidden Files ls -[l]a Standard Input < Standard Error and Output >&1.2. File Manipulation Standard Error SeparatelyDisplay File Contents cat filename ( command > output ) >& errorfileCopy cp source destination Pipes/ Pipelines command | filter [ | filter]Move (Rename) mv oldname newname FiltersRemove (Delete) rm filename Word/Line Count wc [-l]Create or Modify file pico filename Last n Lines tail [-n] Sort lines sort [-n]1.3. File Properties Multicolumn Output pr -tSeeing Permissions ls -l filename List Spelling Errors ispellChanging Permissions chmod nnn filename chmod c=p…[,c=p…] filename 2.3. Searching with grep n, a digit from 0 to 7, sets the access level for the user grep Command grep "pattern" filename (owner), group, and others (public), respectively. c is one of: command | grep "pattern" u–user; g–group, o–others, or a–all. p is one of: r–read Search Patterns access, w–write access, or x–execute access. beginning of line ^Setting Default Permissions umask ugo end of line $ ugo is a (3-digit) number. Each digit restricts the default any single character . permissions for the user, group, and others, respectively. single character in list or range […]Changing Modification Time touch filename character not in list or range [^…]Making Links ln [-s] oldname newname zero or more of preceding char. or pattern *Seeing File Types ls -F zero or more of any character .*1.4. Displaying a File with less escapes special meaning Run less less filename 3. C-Shell Features. Next line RETURN Next Page SPACE 3.1 History Substitution Previous line k Repeat Previous Command !! Previous Page b Commands Beginning with str !str Commands Containing str !?str[?]1.5. Directories All Arguments to Prev. Command !*Change Directory cd directory Word DesignatorsMake New Directory mkdir directory All Arguments :*Remove Directory rmdir directory Last Argument :$Print Working (Show Current) Directory pwd First Argument :^ nth Argument :n
  2. 2. Arguments x Through y :x-y Standard Commands whereis file Modifiers Aliases and Commands which commandPrint Command Line :p Describe Command whatis commandSubstitute Command Line :[g]s/l/r/ Searching Out Files find dir -name name -print dir is a directory name within which to search.3.2 Aliases name is a filename to search for.alias Command alias name definition 6.2. Finding Changes definition can contain escaped history substitution eventand Comparing Files diff leftfile rightfileword designators as placeholders for command-line arguments. diff prefixes a less-than (<) to selected lines from leftfile and a greater-than (>) to lines from rightfile.3.3. Variable SubstitutionCreating a Variable set var 6.3. Automating TasksAssigning a Value set var = value Create a Makefile pico MakefileExpressing a Value $var A makefile consists of macro definitions and targets.Displaying a Value echo $var Test Makefile make -n [target] value is a single word, an expression in quotes, or an Run make make [target] expression that results in a single word after variable, 6.4. Managing Disk Usage filename and command substitution takes place.Assigning a List set var = (list) Check Quota quota -v list is a space-separated list of words, or an expression that Seeing Disk Usage df results in a space-separated list. du -sSelecting the nth Item $var[n] 6.5. Combining and Compressing FilesSelecting all Items $varSelecting a Range $var[x-y] Create a tarfile tar cf file.tar file1 file2 … fileNItem Count $#var tar combines files but does not compress Create a zipfile zip filename3.4 foreach Lists Unzip a file unzip filenameStart foreach Loop foreach var (list) foreach prompts for commands to repeat for each item in 7. Printing list (with >), until you type end. Within the loop, $var 7.1 Formatting Output for Printing stands for the current item in list. Paginate with Page Headers pr filename in n columns pr -n filename3.5. Command Substitution Format for Laser Printer tex documentReplace Command with its Output on Command Line `…` 7.2 The Printer Queue3.6 Job Control Print a File lp [-dpr] filenameRun Command in the Background & lpcae filenameStop Foreground Job CTRL-Z Check Quota lpquotList of Background Jobs jobs List Queue lpqBring Job Forward %[n] Stop Job lprmResume Job in Background %[n] & 8. Miscellaneous4. Processes 8.1 Miscellaneous CommandsListing ps [-[ef]]Terminating kill [-9] PID List Commands for Subject man -k subjectTiming time command Display Current Date and Time date time is a number up to 4 digits. script is the name of a file Log off exit containing the command line(s) to perform. Electronic Mail pine Display Documentation man command5. Users 8.2 Control KeysSeeing Who is Logged In who Abort Program CTRL-C w Backspace (Delete Last Character) CTRL-HSeeing Your User Name whoami Pause Display on Screen CTRL-S Resume Display after CTRL-S CTRL-Q6. Managing Files Send Job to Background CTRL-Z followed by bg6.1. Looking Up Files
  3. 3. Is this document clear? Is it missing crucial information? Please mail comments to the handout editor, CAE, 1410 Engineering Drive, or to: editor@engr.wisc.edu