man – Online UNIX manual (“ man- pages”).
Gives detailed instructions on all of the commands listedhere and a lot more.
cat filename1 > filename2 – Overwrite contents of
filename2 with filename1 .
cat filename1 » filename2 – Append contents of
filename1 to filename2 .
cd /usr – Change current directory to /usr .
cd .. – Change current directory to previous higher
cd – Change to home of current userid.
chgrp group1 filename1 – Change group id to group 1 for filename1 .
chgrp - R group1 * – Change group id of all files in
current and subdirectories to group 1 .
chmod ugo+ rwx filename1 – Add read/ write/ execute
permission to filename1 for user/ owner, group and others (world).
chmod ox filename1 – Remove execute from others (world).
chmod 751 filename1 – Set rwx for user/ owner, rx for group and x for others.
rwx= 421, r= 4, w= 2, x= 1 rx= 5x= 7x= 1.
chown sam filename1 – Change owner of file
filename1 to sam .
chown -R sam * – Change owner to sam for all files incurrent and subdirectories.
clear – Clear the terminal screen.
compress filename1 – Compress file filename1 . See also uncompress .
cp filename1 filename2 – Copy file filename1 to
filename2 destroying the contents of filename2.
cp -i * /usr/ local/ bin – Copy all files in current
directory to /usr/ local/ bin directory. Prompt before overwriting files ( i ).
cpio – Copy file archives to disk/ tape. See man pages.
crontab -e – Edit crontab file for userid.
crontab -e bill – Edit crontab file for user bill .
crontab -l – List crontab entries for current userid.
csh – Start the c shell process. See man pages.
cut d: f1, 5 /etc/ passwd – Extract username & real names from file /etc/ passwd where
delimiter is colon getting fields 1 & 5.
who | cut d" " f1 – List login names from who
date – Display current date string.
date +% D – Display current date as 11/ 21/ 94 format.
dd – Copy file( s) to/ from raw devices. See man pages.
df – Display free disk blocks and modes on file systems.
df -k – Display free space in kilobytes for mounted file systems.
echo name – Displays literal "name" on screen.
echo $PATH – Displays PATH environment variable.
ed/ edit/ ex – Alternative line editors, see vi .
env – Displays current environment variables or allows setting.
file filename1 – Determines and displays type of file
for filename1 (text, data, executable, directory,
symbolic link... etc...).
find /usr/ opt/ bin -name "filename1*" -print – Starts
searching in /usr/ opt/
bin for files starting with
filename1 . If found prints the full file names and
continues searching subdirectories.
find . -type f -print | xargs grep -i [PATTERN] –
Recursive grep for a pattern in a file (searches through files in subdirectories).
find . ! -mtime -< days> | /usr/ bin/ xargs rm -rf –
Finds and removes files older than <days> specified.
finger sam – Displays data about user session for sam .
ftp solar – Establishes a File Transfer Protocol session
over the network between current host and a host
named sola r. See man pages for additional ftp
grep jdoe /etc/ passwd – Searches the file /etc/ passwd searching for string "jdoe" . If found, displays
grep -i Sam filename1 – Search filename1 for upper or lower case string of Sam and display lines found.
sam – List groups that sam is
a member of.
head filename1 – Display first few lines of filename1
head -50 filename1 – Display first fifty lines of
id – List current user id and any group ids.
kill -9 1351 – Terminate process number 1351.
ksh – Start Korn Shell command interpreter. See man pages. Preferred shell for most users.
ln -s filename1 /usr/ opt/ filename2 – Create a
symbolic link named /usr/ opt/ filename2 that points to filename1 . See man pages.
lp -d lp1 filename1 – Print filename1 on destination printer lp1 .
lpstat -d – Displays name of default printer, if any.
lpstat -a – Lists printers accepting print requests.
lpstat -s – Displays most everything regarding printing.
lpstat -u sam – Displays status of sam 's print jobs.
ls -al – Displays all files in wide listing.
ls -al /bin/ k* – Displays files starting with k in /bin
mail sam – Starts mail message to sam .
mailx sam – Nicer looking mail utility.
mkdir -p /usr/ opt/ dirx – Creates dirx below /usr/ opt
make – Code compilation utility.
mkdir dirx – Creates directory dirx .
more filename1 – Displays single pages from
filename1 pausing after each page.
Many options.See man pages.
mv filename1 /usr/ opt/ – Moves filename1 to directory /usr/ opt . Unlike the cp (copy) command, mv removes file from origin.
netstat -i – Show the TCP/ IP network interfaces.
netstat -r – Show network route table.
netstat -rn – Displays routing information but bypasses hostname lookup.
netstat -a | more – Show the state of all sockets.
newgrp group1 – Changes current group to group 1.
news – Displays unread files from /usr/ news or
nice / renice – Adjusts process’ execution priority.
passwd – Allows changing your login password.
ps – Lists all of current user's live processes.
ps -ef – List all users processes that are executing.
pwd – Displays current working directory you are in.
rcp filename1 hostb:/ usr/ local/ bin – Copies
filename1 from current host system to hostb , and
places it in the /usr/ local/ bin directory. The .rhosts or
hosts. equiv files must be setup to allow action.
rksh – Starts restricted Korn Shell session.
rlogin hostb – Logs into remote host name hostb .
rm filename1 – Deletes filename1 from the disk
rm -i filename1 – Deletes filename1 after prompting
rmdir dirx – Deletes directory dirx .
rmdir -r dirx – Deletes directory and all contents.
rsh – Restricted version of Bourne Shell for security.
sar – System Activity Reporter.
sh – Bourne Shell command interpreter. Alternative to
Korn Shell and C shell but is the default on most
systems. Older version that is losing popularity.
sleep 3 – Pauses for 3 seconds and continues.
stty sane – Attempts to restore terminal settings after
they are hosed. Use CTRL- J with this command.
stty erase ^H – Use to reset backspace/ delete. ^H is
the key you may want to use for backspace/ delete.
su sam – Logs you on as user sam .
su - sam – Log on as sam , and execute his profile too.
tail filename1 – Display last few lines of filename1
tail -50 filename1 – Display last fifty lines of
tail -f – Continually reads updating file. Great for
monitoring growth of a log file while being written.
tar -cvf /dev/ rmt/ 0c /usr/ bin/* – Tape archive utility.
Copies all files in /usr/ bin directory to tape device
/dev/ rmt/ .
tar -xvf /dev/ rmt/ 0 /usr/ bin/ – Extracts all files from
tape device /dev/ rmt/ 0 and writes them to /usr/ bin/
tar -tvf /dev/ rmt/ 0c – Read tape on device /dev/ rmt/ 0c
and lists contents in verbose mode.
tee – Used in scripts to split output to two outputs.
Usually used with a pipe command (|).
tee -a /tmp/ filename1 – Append the output to filename1 without overwriting its
telnet hostb – Create a remote terminal on hostb .
filename1 – Creates an
empty file named filename1 .
Changes modification time to current time
if the file already exists.
uname -a – Lists 0/ S revision, host name, hardware.
uncompress filename1 – Uncompresses file with .Z suffix, created by compress command previously.
uptime – Displays current time, time logged- in, number of users etc.
users – Displays current logged- in users in a listing.
uucp – UNIX- to- UNIX copy utility. See man pages.
view filename1 – A read only version of vi editor.
w – Combination of uptime, who and ps -a commands.
wall – Write to all. Allows entry of message to be sent to line 25 of all terminals. End message with
a CTRL- D command.
wc -l filename1 – Utility that counts the number oflines in filename1.
wc -c filename1 – Utility that counts the number of
bytes in filename1 . -m provides number of characters.
wc -w filename1 – Utility that counts the number of the words in filename1 .
whence filename2 – Prints path name location of
executable filename2 .
which filename2 – Similar to whence command.
who – Displays login name, terminal name, date, and time of login, of users currently logged in.
who am i – Displays effective user id of user.
who -b – Displays date/ time of last reboot.
who -r – Displays current system run level.
Visual Editor Commands and Navigation
h, j, k, l left, down, up and right movement
O,$ Jump to front, end of line
w skip to next word
CTRL- D Down one page
CTRL- U Up one page
G Skip to end of file
1G Skip to top of file
CTRL- R or CTRL- L Refresh screen.
/ text Search forward for text.
? text Search backward for text.
n Repeat search after find.
CTRL- G Display current line number.
:99 Move to line number 99 .
a Append after cursor
A Append to end of line
i Insert before cursor
I Insert at beginning of line
o Open new line below cursor
ESC Terminate edit mode return to
cw Change word
cc Change whole line
C Change text to end of line
dd Delete line
5dd Delete current line and next 4
D Delete to end of line
u Undo last change
U Restore current line
yy Yank a copy of current line
p Insert the previously yanked line
Saving and Exiting
ZZ Save and exit file
:wq Same as ZZ
:q! Exit without saving
:n Go to next file to be edited
:w filename1 Save edited file as filename1
Symbols > Redirect output< Redirect input
>> Append to file
| Pipe Output
& Run process in background
; Separate commands
* Match any char( s)
? Match a char