The University of Arizona.
Eller College of Management, The University of Arizona in Tucson, Arizona.
Eller IT.
Explore EllerAcademic ProgramsExecutive EducationFaculty & StaffResearch & InnovationNews & Events

Unix Commands

Conventions used in this QuickReference:
[item] is used to indicate an optional argument
item(s) indicates that you must specify one or more items
"*" indicates that the command reads from a standard input if the file argument is omitted.

File & Directory Management
System Status
Software Development

FILE & DIRECTORY MANAGEMENT

cat Concatenate and print
  cat [options] [file(s)] *
  useful options:

- read from standard input first
- n number of lines
- u output is buffered

     
cd, chdir Change working directory
  cd [dir]
  If no argument specified, change to home directory
     
chmod Change access permission (mode) for file directories
  chmod absolute-mode file(s)
  chmod symbolic-mode file(s)
  useful options:

Absolute:
4 read Access
2 write access
1 execute (search) access

Symbolic:
r read access
w write access
x execute (search) access
u user (owner)
g group
o other
a all

     
cp Copy files
  cp file1 file2
  cp file(s) directory
     
file Determine file type
  file file(s)
     
find Find files
  find pathname-list expression
  Find all files in pathname-name that match expression
  Useful options: (options may be combined)

-name filename

True if filename matches the current file name

-perm octnum

True if the permission matches the octal number octnum

-print

display the file name

-type t

True if the type of the file is t, where t is d (directory), f (file), c (character special file), or b (block special file)

-exec command

True is the executed command returns a zero exit status. Replace # with the current pathname. An escaped semicolon follows command

-size n

True if the file is size n (greater than n is +n and less than n is -n)

-mtime n

True if the file has been modified in n days

     
head Display in front of file
  head [-count] [file(s)] *
  Display the first (10 or -count) lines of file(s)
     
ln Make links
 

1. ln file1 [file2]
2. ln file(s) directory
3. ln [-s] file1 [file2]

In form 1, ln create a link called file2 to an existing file1. If file2 is not specified, the link is created in the current directory with file1's file name.

In form 2, ln creates a link in directory to each file named. You cannot link to directories or across the system. Form 2 allows symbolic links (-s option), which may be made across file systems (BSD only).

     
ls List directory content
  ls [options] [name(s)]
  List the content of each directory name or status in formation of each file name. If name is omitted, use current directory.
  Useful options:

-l list in long format
-a list entries including those starting with . (dot)
-F mark directories with a trailing /, executable file with *
-R list subdirectories recursively
-1 force Output to consist of one entry per line

     
mkdir Make a directory
  mkdir dir(s)
     
more Page output to screen
  more [options] [file(s)]
  Display files on screen. Type q to quit display, SPACE to continue, h for help.
     
mv Move or rename a file or directory
  mv oldname newname
  Moves or renames file oldname to newname. If newname exists, it is replaced by oldname. If oldname is a directory, only a rename is possible.
     
rm Remove file
  rm [options] [file(s)]
  Useful options: -f do not attempt to verify removal (force removal)
-i interactive prompt to remove each file
-r delete each file and subdirectory recursively
     
rmdir Remove directory
  rmdir dir(s)
     
tail Display tail end of file
  tail [options] [file(s)]
     
tee Read standard input and write to standard output
and file(s)
  tee [options] [files (s)]
  Useful options: -i ignore Interrupts
-a append to file(s)

SYSTEM STATUS

date Give the system date and time
     
du Disk usage
  du [options] [dir(s)]
  Summarize disk usage for directory dir or for if dir is not specified.
  Useful Options: -s give total only
-a give size of each file
     
env Display the current environment variables
     
id Give user and group identification
     
kill Terminate a process
  kill [-signal_number] process_id(s)
     
mail Send or read mail
  (different versions of this program exist on different systems)
     
news Read system news
  (different versions of this program exist on different systems)
  news may include a network bulletin board as well as local items.
     
ps Process status
  ps [options]
  (Report process information for user or system processes. Options allowed may vary.)
     
pwd Print working directory
  Give full pathname of current working directory
     
stty Set or display terminal characteristics
  stty [options]
     
tset Terminal set program
  tset [options] terminal -id
  tell UNIX what kind of terminal you have
  Useful options: - write the name of the terminal to the standard output
-ec set erase character to c
-kc set kill character to c
     
tty Display special device corresponding to current terminal
     
whereis (BCD only) gives pathnames corresponding to command
     
who Who is logged onto UNIX
     
write Write to another user
  write user [ttyname]
  write sends lines of text form your terminal to user. If user is logged on more than once, you may specify a tty identification. user responds by executing concurrently, write terminates when it reads an EOF.

SOFTWARE DEVELOPMENT

ar Archive and library maintainer
  ar key [position] library member_name (s)
  Archive according to key using archive file library and constituents member_name
  Keys: d delete
r replace
q append quickly
t produce a table
p print the named member_names
m move
x extract
     
cb C beautifier
  cb reads the standard input and produces a C program with appropriate spacing and indentation to indicate its structure
     
cc C compiler
  cc [options] file(s)
  Compile file(s) using named options. Files must be of the form file.c
  Useful options: -c produce an object file but don't call the loader
-o out name the output file out instead of a.out
-s strip the symbol table
-O optimize the object code
     
cmp Compare two files
  cmp [options] file1 file2
  Compare files file1 and file2, If file1 is -, the standard input is used. Exit code 0 means the files are the same, 1 means the files differ, and 2 means the file is not accessible or an argument is missing.
  Useful options: -l display the byte number and the differing bytes for each difference (long listing)
-s no output; just return proper exit codes
     
nm Display namelist
  nm [options] [file(s)]
  nm displays the symbol table of each file in the argument list. If no file is specified, a.out is used.
  Useful options: -g display global symbols
-n sort Output numerically (instead of alphabetically)
-u display only undefined symbols
     
od Octal, decimal, hexadecimal, or ASCII dump
  od [option] [file(s)] *
  od displays file (or the standard input if no file is specified) in format indicated in option. Octal is the default format.
  Useful options: -a bytes as ASCII format
-b bytes as unsigned octal
-d words as unsigned decimal
-h words as unsigned hexadecimal
-o words as unsigned octal
-x words as hexadecimal
     
size Size of an object file
  size [object_file(s)]
  Display the number of bytes required by the text, data and BSS portion of an object file. Displays sum in hexadecimal and decimal. If no object_file is specified, size uses a.out.

 

  

 
   
Resources:
 
 
  
Eller IT Orientation Packet
Blackboard How-To Helpers
Extended University
UA Library Workshops
Multimedia Learning Lab Computer Workshops
Learning Technology Center   
 
 
  
Eller College Home   |   UA   |   Disclaimer   |   Privacy   |   Site Index

Eller College of Management   |   The University of Arizona
1130 E. Helen Street   |   P.O. Box 210108   |   Tucson, AZ 85721-0108   |   520.621.2165
  
© Copyright 2008 The University of Arizona. All rights reserved.
  

The University of Arizona : Arizona's First University.