theCAT
  
Report a Problem:
Email: support@cat.pdx.edu
Phone: 503-725-5420
Location: FAB 82-01
  USERS PLATFORMS SYSTEM RESOURCES    
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  
Linux
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.
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> cat filename
cd Use cd to Change Directories. NOTE: If directoryname is not in the current directory you must include the path.
systemname.domain.pdx.edu> cd directoryname
systemname.domain.pdx.edu> cd path/directoryname
chgrp CHanges the GRouP a file belongs to.
systemname.domain.pdx.edu> chgrp groupname filename
chmod This command allows either the owner of the file or the owner of the directory to CHange MODes (file permissions).
systemname.domain.pdx.edu> chmod go+rx filename
Modes:
  • 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.
systemname.domain.pdx.edu> clear
cp Use cp to CoPy files.
systemname.domain.pdx.edu> cp source_filename target_filename
diff This command can be used to look for DIFFerences between two files.
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> exit
find This command will recursively descend the directory you specify to locate files.
systemname.domain.pdx.edu> find directory -name filename -print
grep Use this command to search a file or standard out for a pattern (string) you specify.
systemname.domain.pdx.edu> grep pattern filename
groups Use this command to show the groups a user belongs to.
systemname.domain.pdx.edu> groups username
gunzip Use this command to uncompress a zipped file (zipped files have a .gz suffix).
systemname.domain.pdx.edu> gunzip filename.gz
gzip Use this command to compress (zip) a file (when a file is zipped the .gz suffix is added automatically).
systemname.domain.pdx.edu> 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).
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> ln sourcefile linkname
logout Use this built-in shell function to logout of your current login shell.
systemname.domain.pdx.edu> logout
lpq Shows the print queue of the printer you specify.
systemname.domain.pdx.edu> lpq -Pprintername
lpr Use this command to print a file.
systemname.domain.pdx.edu> lpr -Pprintername filename
lprm This command is used to remove a job from the print queue (use lpq to find the job number).
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> man ls
Reformatting page. Wait...
mkdir Use this command to MaKe a DIRectory.
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> more filename

systemname.domain.pdx.edu> ls | more
Directoryname1
Filename1
directoryname2
filename2

--More--
mv Use this command to rename or MoVe a file to another directory.
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> ps -ef | grep username
pwd This command shows the full path of your Present Working Directory.
systemname.domain.pdx.edu> pwd
/u/username/directoryname
rm ReMove files from a directory. You will not be able to recover a file that has been deleted!
systemname.domain.pdx.edu> rm filename
rmdir ReMove an empty DIRectory. You will not be able to recover a directory that has been deleted!
systemname.domain.pdx.edu> 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:
systemname.domain.pdx.edu> source ~/.bashrc
ssh This program is a Secure SHell client. Use ssh to login to remote computers.
systemname.domain.pdx.edu> ssh username@hostname.domain.pdx.edu
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 :
systemname.domain.pdx.edu> 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 :
systemname.domain.pdx.edu> 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.
systemname.domain.pdx.edu> 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).
systemname.domain.pdx.edu> which netscape
/usr/local/bin/X11/netscape
Last Updated ( Friday, 26 August 2016 )

©1999 - 2017 TheCAT