Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Frequently Used UNIX Commands

U-M Information Technology Division

1 of 2

Reference R1159 November 1999

The Unix operating system supports many commands. To review a more complete definition of any of the commands listed below, type man command at the Unix shell prompt (%), where command is the name of a Unix command.
NOTE : This document assumes you are using Unix on the ITD Login Service (host name

login.itd.umich.edu). The Login Service is a set of Sun workstations running the Solaris 2.5.1 operating system. These instructions apply to many other Unix machines; however, you may notice different behavior if you are not using the ITD Login Service.
TIP: The variable files refers to a list of any number of files separated by white space; in the same

way, names refers to a list of file or directory names separated by white space.

General
apropos command exit man command Locate commands by keyword lookup Terminate your current session, or shell Display the Unix manual page describing a given Unix command

File System Navigation


cd cd directory file files ls ls names ls -l ls -a ls -R ls -t pwd Return to your home directory Change directory to make directory your current directory Determine file type List the contents of the current directory List the contents of the directories; names can name files and/or directories . . . in a long format, showing permissions, owner, size, and other file info . . . all files, including hidden files (file names that begin with a dot .) . . . Recursively, for all subdirectories . . . in time order (when modified, newest to oldest) rather than in name order Display the name of the current directory, or print working directory

File/Directory Manipulation
compress files uncompress files cp file1 file2 cp files directory cp -r dir1 dir2 mkdir directory mv file1 file2 mv files directory mv dir1 dir2 rm files rm -r names rmdir directory Reduces the size of a file Restores compressed files to their original form Copy file(s) Copy file(s) into a directory Copy a directory and, recursively, its subdirectories Create, or make a directory Move a file or, if file1 and file2 are in the same directory, rename a file Move files into a directory If directory dir2 exists, move dir1 into dir2; otherwise, rename dir1 as dir2 Remove (erase) file(s) Remove files, directories, and recursively, any subdirectories Remove directory (directory must be empty)

Frequently Used Unix Commands

2 of 2

Data Manipulation
cat files grep pattern files more files sort files sort -r files sort -n files Concatenate file(s); you can use cat to display the contents of a file (this is not advisable if the file is a binary file) Display all lines in the files that match a pattern Display contents of files one screen at a time Order the lines in a file or files alphabetically (this command does not alter the file or filesit merely displays the sorted output to the screen) . . . in reverse order . . . numerically (puts 2 before 10 instead of after)

Networking/Communications
finger user telnet hostname talk user Displays information about a user (to display information from the campus section of the Online Campus Directory, type finger uniqname@umich.edu) Connect to another remote system using the telnet protocol Initiate a conversation with another user (end conversation with Control-C). talk works only between machines of the same architecture

Miscellaneous
!! !string cal cal month year clear date who Repeat last shell command Repeat last shell command that began with string (for example, type !m to repeat the last command that began with m) Display a calendar of the current month Display a calendar of the given month and year. Note that the year must be fully qualified, for example, 1994 and not 94 Clears terminal screen Display the current local date and time Display a list of users currently logged in

Additional Resources
Visit ITDs Information System (http://www.itd.umich.edu/itddoc/) to obtain ITD computer documentation and other resources. A list of relevant documents follows. Accessing ITDs Login, Statistics and Computation, and UMCE Subscription Services (S4157) Create, Copy, Rename, and Remove Unix Files and Directories (S4148) List Contents and Navigate Unix Directories (S4149) Using the Unix Text Editor Pico (R1168) Using the Unix Text Editor vi (R1172) We welcome your comments; please send e-mail to itd.doc.comments@umich.edu. ITDs Online Help Desk (http://www.itd.umich.edu/help/) provides a variety of computing help resources. s

You might also like