SlideShare a Scribd company logo
1 of 3
Download to read offline
Unix Commands
                                                   Unix                                                                 January 2003

This quick reference lists commands, including a syntax diagram      2. Commands
and brief description. […] indicates an optional part of the         2.1. Command-line Special Characters
command. 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, Continuation
1.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 Pipes
Home 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 Separately
Display File Contents                          cat filename                                    ( command > output ) >& errorfile
Copy                                   cp source destination         Pipes/ Pipelines                   command | filter [ | filter]
Move (Rename)                          mv oldname newname               Filters
Remove (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 -t
Seeing Permissions                                ls -l filename     List Spelling Errors                                   ispell
Changing 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 Designators
Make New Directory                            mkdir directory        All Arguments                                                :*
Remove Directory                              rmdir directory        Last Argument                                                :$
Print Working (Show Current) Directory                   pwd         First Argument                                               :^
                                                                     n'th Argument                                                :n
Arguments x Through y                                      :x-y      Standard Commands                               whereis file
    Modifiers                                                        Aliases and Commands                          which command
Print Command Line                                          :p       Describe Command                             whatis command
Substitute 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 event
and                                                                  Comparing Files                              diff leftfile rightfile
word 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 Substitution
Creating a Variable                                     set var      6.3. Automating Tasks
Assigning a Value                              set var = value       Create a Makefile                           pico Makefile
Expressing 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 -s
Selecting the n'th Item                                   $var[n]
                                                                     6.5. Combining and Compressing Files
Selecting all Items                                          $var
Selecting a Range                                       $var[x-y]    Create a tarfile         tar cf file.tar file1 file2 … fileN
Item Count                                                  $#var       tar combines files but does not compress
                                                                     Create a zipfile                              zip filename
3.4 foreach Lists                                                    Unzip a file                                unzip filename
Start 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 filename
3.5. Command Substitution
                                                                     Format for Laser Printer                          tex document
Replace Command with its Output on Command Line            `…`
                                                                     7.2 The Printer Queue
3.6 Job Control
                                                                     Print a File                                lp [-dpr] filename
Run Command in the Background                                  &                                                    lpcae filename
Stop Foreground Job                                       CTRL-Z     Check Quota                                           lpquot
List of Background Jobs                                    jobs      List Queue                                                 lpq
Bring Job Forward                                            %[n]    Stop Job                                                  lprm
Resume Job in Background                                  %[n] &
                                                                     8. Miscellaneous
4. Processes
                                                                     8.1 Miscellaneous Commands
Listing                                            ps [-[ef]]
Terminating                                     kill [-9] PID        List Commands for Subject                        man -k subject
Timing                                            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 command
5. Users
                                                                     8.2 Control Keys
Seeing Who is Logged In                                   who
                                                                     Abort Program                                                CTRL-C
                                                            w
                                                                     Backspace (Delete Last Character)                            CTRL-H
Seeing Your User Name                                  whoami        Pause Display on Screen                                      CTRL-S
                                                                     Resume Display after CTRL-S                                  CTRL-Q
6. Managing Files                                                    Send Job to Background                      CTRL-Z   followed by bg
6.1. Looking Up Files
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

More Related Content

What's hot (14)

Unix reference sheet
Unix reference sheetUnix reference sheet
Unix reference sheet
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Unix cmd
Unix cmdUnix cmd
Unix cmd
 
Doscommands
DoscommandsDoscommands
Doscommands
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Rf介绍
Rf介绍Rf介绍
Rf介绍
 
Commands
CommandsCommands
Commands
 
Unix practical file
Unix practical fileUnix practical file
Unix practical file
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
 

Similar to Unix

Lecture1 3 shells
Lecture1 3 shellsLecture1 3 shells
Lecture1 3 shellsnghoanganh
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent cardBui Van Cuong
 
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetgnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetlinkedinstaging
 
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetgnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetlinkedinstaging
 
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetgnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetlinkedinstaging
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 
Quick guide of the most common linux commands
Quick guide of the most common linux commandsQuick guide of the most common linux commands
Quick guide of the most common linux commandsCarlos Enrique
 
Unix Trainning Doc.pptx
Unix Trainning Doc.pptxUnix Trainning Doc.pptx
Unix Trainning Doc.pptxKalpeshRaut7
 
Kali Linux Commands PDF-converted.pdf
Kali Linux Commands PDF-converted.pdfKali Linux Commands PDF-converted.pdf
Kali Linux Commands PDF-converted.pdfSN 600W
 
List command linux a z
List command linux a zList command linux a z
List command linux a zJinyuan Loh
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commandsBen Pope
 
unix_ref_card.pdf
unix_ref_card.pdfunix_ref_card.pdf
unix_ref_card.pdfGiovaRossi
 
unix_ref_card.pdf
unix_ref_card.pdfunix_ref_card.pdf
unix_ref_card.pdfGiovaRossi
 

Similar to Unix (20)

Lecture1 3 shells
Lecture1 3 shellsLecture1 3 shells
Lecture1 3 shells
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
 
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetgnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheet
 
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetgnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheet
 
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheetgnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheet
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Quick guide of the most common linux commands
Quick guide of the most common linux commandsQuick guide of the most common linux commands
Quick guide of the most common linux commands
 
archive A-Z linux
archive A-Z linuxarchive A-Z linux
archive A-Z linux
 
Unix Trainning Doc.pptx
Unix Trainning Doc.pptxUnix Trainning Doc.pptx
Unix Trainning Doc.pptx
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Kali Linux Commands PDF-converted.pdf
Kali Linux Commands PDF-converted.pdfKali Linux Commands PDF-converted.pdf
Kali Linux Commands PDF-converted.pdf
 
Kali linux commands
Kali linux commandsKali linux commands
Kali linux commands
 
List command linux a z
List command linux a zList command linux a z
List command linux a z
 
Unix
UnixUnix
Unix
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
 
unix_ref_card.pdf
unix_ref_card.pdfunix_ref_card.pdf
unix_ref_card.pdf
 
unix_ref_card.pdf
unix_ref_card.pdfunix_ref_card.pdf
unix_ref_card.pdf
 

Unix

  • 1. Unix Commands Unix January 2003 This quick reference lists commands, including a syntax diagram 2. Commands and brief description. […] indicates an optional part of the 2.1. Command-line Special Characters command. 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, Continuation 1.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 Pipes Home 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 Separately Display File Contents cat filename ( command > output ) >& errorfile Copy cp source destination Pipes/ Pipelines command | filter [ | filter] Move (Rename) mv oldname newname Filters Remove (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 -t Seeing Permissions ls -l filename List Spelling Errors ispell Changing 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 Designators Make New Directory mkdir directory All Arguments :* Remove Directory rmdir directory Last Argument :$ Print Working (Show Current) Directory pwd First Argument :^ n'th Argument :n
  • 2. Arguments x Through y :x-y Standard Commands whereis file Modifiers Aliases and Commands which command Print Command Line :p Describe Command whatis command Substitute 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 event and Comparing Files diff leftfile rightfile word 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 Substitution Creating a Variable set var 6.3. Automating Tasks Assigning a Value set var = value Create a Makefile pico Makefile Expressing 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 -s Selecting the n'th Item $var[n] 6.5. Combining and Compressing Files Selecting all Items $var Selecting a Range $var[x-y] Create a tarfile tar cf file.tar file1 file2 … fileN Item Count $#var tar combines files but does not compress Create a zipfile zip filename 3.4 foreach Lists Unzip a file unzip filename Start 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 filename 3.5. Command Substitution Format for Laser Printer tex document Replace Command with its Output on Command Line `…` 7.2 The Printer Queue 3.6 Job Control Print a File lp [-dpr] filename Run Command in the Background & lpcae filename Stop Foreground Job CTRL-Z Check Quota lpquot List of Background Jobs jobs List Queue lpq Bring Job Forward %[n] Stop Job lprm Resume Job in Background %[n] & 8. Miscellaneous 4. Processes 8.1 Miscellaneous Commands Listing ps [-[ef]] Terminating kill [-9] PID List Commands for Subject man -k subject Timing 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 command 5. Users 8.2 Control Keys Seeing Who is Logged In who Abort Program CTRL-C w Backspace (Delete Last Character) CTRL-H Seeing Your User Name whoami Pause Display on Screen CTRL-S Resume Display after CTRL-S CTRL-Q 6. Managing Files Send Job to Background CTRL-Z followed by bg 6.1. Looking Up Files
  • 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