UNIX COMMANDS
CAL [month] year Print calendar
cal displays calendar
month = 1 to 12
year = 1 to 9999
CAT Concatenate and Print
$cat file displays file
CD Change working directory
cd return to login directory
cd dirname change working directory to dirname
CHMOD Change permission mode for file
chmod [who] op-code permission... file...
who:
o others
g group
u Login owner
a all of above
op-code:
+ add permission
- remove permission
= assign absolute permission
permission:
r read
w write
x execute
CP Copy File
cp file1 file2 copy file1 and name new copy as file2
DIFF Differential File Comparator
diff [options] file1 file2 find difference between file1 and file2
options:
-b ignore spaces and tabs in comparison
-e ed script option
-f opposite order script
-h simple, fast, less-rigorous comparison
ECHO Echo arguments
echo [arg]... echo arg to standard output
FIND Find Files
find pathname-list... condition...
options:
-atime n last accessed day n
-exec cmd execute cmd if file meets conditions
-group gname file owner gname
-links n number of links to file
-mtime n last modified day n
-name file specify filename
-newer file file modified more recently than file
-ok cmd execute cmd only on 'y' response
-print display the file pathname
-size n file size in blocks
-type c specify file-type
b block
c character
d directory
f plain file
-user uname file owner uname
GREP Search file for pattern
grep [options] pattern file... find lines in file matching pattern
options:
-c count of matching lines
-e use if pattern begins with '-'
-h header display suppressed
-l list of filenames containing pattern
-n line number of lines which match
-v variant: all lines except matches
-y lowercase pattern will match uppercase
LP Line print spooler
lp [options] file... place file in line printer queue
options:
-c make copy of file for queue
-ddestprn specify destprn as destination printer
-fformname use the form specified by formname
-m report by mail when printed
-nx print x copies
-r remove file after placing in queue
-ttitle specify title as banner
-w write message on terminal after printing
LS List Contents of Directory
ls [options] name... list contents of directory
options:
-a all entries
-d directory status information
-l long format
-r reverse order listing
-s size in blocks
-t sort by time modification
-u sort by last access time
-x multi-column across page
MAN On-line Manual
man [options] section title locates and displays pages of unix manual
options:
-a all matching title
-f first matching title
-w prints pathname to manual section
MESG Permit or Deny Messages
mesg [options] report or set write permission on terminal
options:
-n deny non-user write permission
-y enable non-user write permission
MKDIR Make a Directory
mkdir dirname... create directory
MV Move a file or directory
mv file1 file2 change name of file1 to file2
mv dir1 dir2 rename dir1 directory to dir2 directory
mv file... dname move one or more files to directory dname
PASSWD Change Login Password
passwd change your password
PR Print File with Pagination
pr [options] file... formatted printing of file...
options:
-a multi-column across page
-d double space output
-f use form-feed character as page break
-h "title" customized page heade title
-ln page length n lines
-m print all files... in multiple columns
-n produce n-column output
+n start printing at page n
-sc seperate columns with character c
-t no header printed
-wn page width n characters
PS Process Status
ps [options] processnumber print information about active processes
options:
-a all processes except group leaders and non-terminal processes
-e all processes
-l long listing
PWD Print Working Directory
pwd display current working directory
RM Remove files or directories
rm [options] file... remove one or more files
options:
-f force removal of write-protected files
-i interactive delete
-r recursively delete directory
SORT Sort or Merge Files
sort [options] [+pos1] [-pos2] [-ofileout] filein...
options:
-b ignore leading blanks and tabs
-c check if sorted
-d dictionary order
-f ignore case
-i ignore non-printable characters in non-numeric comparisons
-M compare as months
-m merge the files, input files are already sorted
-n sort on first numeric field
-r reverse order of sort
-tx field seperator is x
-u eliminate duplicate lines
+pos1, -pos2 restrict sort key to beginning at pos1 and ending at pos2
-ofileout write output to outfile
TAIL Deliver last part of a file
tail [+-n] file copy file to stdout +n from beginning to -n from end of file
TEE Pipe fitting
tee [options] file... divert a copy into file...
options:
-a append to file
-i ignore interrupt signals
-u unbuffered output
UNIQ Remove repeated lines in a sorted file
uniq [options] input [output] remove repeated adjacent lines in input file when copying to output file
options:
-u display lines not repeated in input
-d display one copy of repeated lines in input
-c precede each line with number of times repeated
-n ignore the first n fields
+n ignore the first c characters
WC Word Count
wc [options] file... count lines, words and characters in file...
options:
-c count characters
-l count lines
-w count words
WHO Who is on the system
who list user login name, terminal and login time
WRITE Write to another user
write user [ttyname] write to user on terminal, ttyname the ttyname is optional.
HEAD
This is used to view the first few lines of a file. It accepts a switch specifying the number of lines to view.
NEWS
The news command keeps the user informed of current events.
DF
it reports number of free disk blocks, and i-nodes
DU
Summarizes disk usage in a specified directory hierarchy
LN
Creates a hard link (default), or a soft link (with -s option)
MOUNT, UMOUNT
Attaches, or detaches, a file system (super user only)
MKFS
Constructs a new file system (super user only)
FSCK
Evaluates the integrity of a file system (super user only)
FINGER
finger displays information about one or more Linux users. GNU finger supports a single host that can act as the finger server host in sites that have multiple hosts. This host collects information about who is logged into other hosts at that site. Thus, a query to any machine at another site will return complete information about any user at that site.
NICE
run a program with modified scheduling priority SET
Typing the set command will print out a list of all the current shell environments. This is a list of all the variables and settings that the shell currently has.
SHELL VARIABLES
The shell supports user and system variables. An example of system variables are,
PS1 system prompt
PS2 secondary line shell prompt
HOME home directory
LOGNAME login name
Variables are assigned values using the = sign.