Basic Unix Survival Guide

Basic Unix Survival Guide


Note: Unix is case sensitive. Passwords are case sensitive. All commands are lowercase; command options may be either upper or lower case. The authoritive reference for commands is the manpages on the system you are using.

.denotes current directory; e.g. cp /usr/test.dat . will copy file to current directory
*will match any filename; e.g. rm * will remove all files
?will match one character in a filename; e.g. rm data.? will remove data.1
\interpret the next character as a literal; e.g. mv andor and\/or
cat file1display file1
cat file1 file2 > newfilecombines file1 and file2 into newfile
cat file1 >> file2append file1 to file2
cdreturn to the home directory
cd ..move up one directory level
cd ../..move up two directory levels
cd directorymove to directory one level down
chmod u+w filenameadd write permission for the user to file1
chmod g+x filenameadd execute permission for the group to file1
chmod o-r filenameremove read permission for the world from file1
chmod 700 filenameallow rwx permissions for owner only on file1
cp file1 file2copy file1 to file2
cp file1 directorycopy file1 into specified subdirectory
cp file1 file2 directorycopy two files into specified directory
cp -r dir1 dir2copy all files and subdirectories in dir1 into dir2
cp ../dir/file .copies file1 from a sister directory into current directory
echo $PATHdisplay value of environmental variable such as $TERM, $SHELL, $HOME
grep string *.cWill find all instances of string in all files ending with .c in current directory
kill pidgracefully kills the specified process. obtain pid from ps
kill -9 pidungracefully kills the process
iddisplay user's system identity
logout or exit or CTRL-Dterminates a session
ln -s /pathname/file1creates a symbolic soft link to file1 named file1 in the current directory
ln -s /pathname/dir1creates a symbolic soft link to dir1 named dir1 in the current directory
logout or exit or CTRL-Dterminates a session
lpr -P printer filenameprints file to the specified printer.e.g. lpr -Pcstext lab5.txt
ls | more lists a directory in columns one page at a time
ls -lgives a fuller listing including file permissions, size, date created
ls -alsimilar to the above but includes "dot" files
man commanddisplay reference manual for command. hit 'q' to quit or SPACE to continue
man -k keywordshows all of the man pages that contain keyword
man command | col -b | lpr -PprinterPrints out the specified man page
mkdir subdirectory create a subdirectory in the current directory
more filename list file one screen at a time. press SPACE to continue; press q to cancel
mv oldfile newfilerename file
mv old_dir new_dirrename directory
mv dir1 dir2move dir1 into dir2
mv file1 file2 dirmove specified files into directory
passwdchange password
pslist all processes for the current user and their status
ps aulist all processes for all users and some extra status information
pwdprint current working directory
rm filenamedelete the specified file
rm -i filenamedeletes the file after confirmation
rm -rf directory remove the directory and all files and directories contained within
rmdir directory removes directory if empty

General Tips

If a program is locked up execute ps -ef | grep username (this lists all your processes). From here, find the PID of the offending process (the second column in the output), and do a kill (-9 if needed) pid. If the terminal you are working on is locked up, open a terminal session from do the same from there.

Pegasus security prevents users from executing ~ (to specify your root directory) and chsh (to change your shell).


Back to computer science home page