Report a Problem:
Phone: 503-725-5420
Location: FAB 82-01
Home Students Fac/Staff CS Tutors Guidelines Windows Linux Mac Mail Network Software Web TheCAT Sitemap Contact
arrowHome arrow Linux arrow Basic Shell Commands Wednesday, 29 March 2017  
Basic Shell Commands Print
Written by fester   
Monday, 19 September 2005

For detailed information on UNIX commands type "man command" where "command" is the command name you are looking for more info on.

apropos Searches the man pages for a keyword you specify. The name of the man page is in the first column.> apropos floppy
eject eject (1) - eject media such as CD-ROM and floppy from drive
fd fd (7d) - drivers for floppy disks and floppy disk controllers

cat This command will display the contents of a file.> cat filename
cd Use cd to Change Directories. NOTE: If directoryname is not in the current directory you must include the path.> cd directoryname> cd path/directoryname
chgrp CHanges the GRouP a file belongs to.> chgrp groupname filename
chmod This command allows either the owner of the file or the owner of the directory to CHange MODes (file permissions).> chmod go+rx filename
  • u ~ user's permissions
  • g ~ group's permissions
  • o ~ other's permissions
  • a ~ all permissions (user, group, and other)
  • + ~ add permissions
  • - ~ remove permissions

clear This command clears the screen.> clear
cp Use cp to CoPy files.> cp source_filename target_filename
diff This command can be used to look for DIFFerences between two files.> diff fileA fileB
exit If you initialize a new shell with a command like csh you can use the built-in shell function exit to quit the new shell.> exit
find This command will recursively descend the directory you specify to locate files.> find directory -name filename -print
grep Use this command to search a file or standard out for a pattern (string) you specify.> grep pattern filename
groups Use this command to show the groups a user belongs to.> groups username
gunzip Use this command to uncompress a zipped file (zipped files have a .gz suffix).> gunzip filename.gz
gzip Use this command to compress (zip) a file (when a file is zipped the .gz suffix is added automatically).> gzip filename
kill Use this command to terminate runaway processes that you own (type the command ps to find your active processes and their PIDs - process identity numbers).> kill -9 PID#
ln Use this command to create a LiNk, which allows a file to be accessed by a different name. Links may be removed with the rm command.> ln sourcefile linkname
logout Use this built-in shell function to logout of your current login shell.> logout
lpq Shows the print queue of the printer you specify.> lpq -Pprintername
lpr Use this command to print a file.> lpr -Pprintername filename
lprm This command is used to remove a job from the print queue (use lpq to find the job number).> lprm -Pprintername job#
Printer printername@speedracer:
checking perms 'username@hostname+job#'
dequeued 'username@hostname+job#'
ls This command ListS the contents of the directory. Add the -l option to view the "Long format," which shows the mode (permissions), number of links, owner, group, size in bytes, time of last modification, and file or directory name.> ls -l
total 12
drwxr-xr-x 2 user group 512 Oct 23 2000 Directoryname1
-rw------- 1 user group 1802 Dec 20 1999 Filename1
drw------- 7 user group 1024 May 15 11:40 directoryname2
-rw------- 1 user group 64 Mar 5 12:20 filename2
man Use the man command to view the complete MANual page or "man page" that you select by name.> man ls
Reformatting page. Wait...
mkdir Use this command to MaKe a DIRectory.> mkdir directoryname
more Displays the contents of a file or standard out one page at a time. Press ‹Space› to go to the next page.> more filename> ls | more

mv Use this command to rename or MoVe a file to another directory.> mv source_filename target_filename
ps Shows information about processes. You can use the command shown below to see the full listing of every processes you have running, or just type ps to see the short listing of your active processes.> ps -ef | grep username
pwd This command shows the full path of your Present Working Directory.> pwd
rm ReMove files from a directory. You will not be able to recover a file that has been deleted!> rm filename
rmdir ReMove an empty DIRectory. You will not be able to recover a directory that has been deleted!> rmdir directoryname
source Reads commands from a file. For example, if you make changes to your .bashrc file and you don't want to logout and then log back in for the changes to take effect, just source the file:> source ~/.bashrc
ssh This program is a Secure SHell client. Use ssh to login to remote computers.> ssh
tar Use this command to archive files or directories.

This example will archive the directory directory_to_tar and all of it's files and subdirectories to an archive called new_archive.tar :> tar cvf new_archive.tar directory_to_tar

This example will extract all of the files (and directories) from the archive named tarfile.tar into the directory called target_directory :> tar xvf tarfile.tar target_directory
touch Use this command to set the access and modification times of a file, or if the file named doesn't exist, touch will create an new, empty file.> touch filename
which This built-in shell function shows you where a command or binary (executable), is located (i.e. "WHICH one" you are using).> which netscape
Last Updated ( Friday, 26 August 2016 )

©1999 - 2017 TheCAT