Common Unix Commands

General Syntax: $ <command name> <options> <argument1> <arg2> <arg3> ...

CmdSyntaxExamplesDescription
pwd pwd $ pwd Print the current working directory
ls ls <directory> $ ls
$ ls -a
$ ls -laF ~/public
List contents of a directory
cd cd $ cd ../private/files Change current working directory
man man <command name> $ man ls
$ man pwd
$ man man
Get manual page for command
cp cp <src path> <destination path> $ cp file1.txt public/cs110/ Copy a File
mv mv <src path> <destination path> $ mv file2.txt textfile.txt
$ mv file1.txt ../../public/html/hello.html
Move or Rename a file
rm rm <path> $ rm public/html/hello.html
$ rm temp.txt
Delete a file
mkdir mkdir <path to create> $ mkdir cs110
$ mkdir /afs/pitt.edu/home/x/x/xxx99/cs110
Create a directory
rmdir rmdir <path> $ rmdir /afs/pitt.edu/home/x/x/xxx99/cs110 Remove a directory
echo echo <src path> $ echo "A line of text"
$ echo Another line of text
Print text to the terminal
ln ln <src path> <destination path> $ ln file.txt ../public/file.txt
$ ln ../private/docs/file.doc .
$ ln -s ../file.html .
link file to another path (with -s option, it creates a shortcut)
who who $ who
$ whoami
Display other users currently logged into the system
finger finger <search criteria> $ finger xxx99
$ finger Smith
Search user information
cat cat <path1> <path2> ... $ cat file1.txt file2.txt file3.txt
$ cat -
$ cat file3.txt >> file4.txt
Concatenate files
less less <path> $ less file1.txt
$ cat file1.txt | less
Display a file (or any output) one screen at a time with scrolling
more more <path> $ more file2.txt
$ cat file2.txt | more
Display a file (or any output) one screen at a time
find find <path> <option1> <arg1> <opt2> <arg2> ... $ find ~/public -name "*.txt" Search for files
grep grep <search criteria> <path or files> $ grep "<html>" ~/public/html Search contents of files
chmod chmod <new permissions> <path> $ chmod 0777 file.txt
$ chmod u+x file.txt
$ chmod a-w ../public/file.txt
Change file permissions (Unix only)
fs fs <subcommand> <args> $ fs lq
$ fs la
$ fs help
$ fs sa ~/cs110 xxx99 rlwid
AFS utility (file permissions on AFS)
script script <path> $ script typescript.txt
$ script
Begin recording keystrokes to a file
lpr lpr <path> $ lpr file.txt Send afile to a printer
zip zip <destination path> <file1> <file2> ... $ zip files.zip file1.txt file2.txt file3.txt Create a ZIP archive
unzip unzip <path> $ unzip files.zip Extract files from a ZIP archive
telnet telnet <address> $ telnet unixs.cis.pitt.edu connect to a remote system
ssh ssh <address> $ ssh unixs.cis.pitt.edu
$ ssh xxx99@unixs.cis.pitt.edu
connect to a remote system (securely)
ftp ftp <address> $ ftp unixs.cis.pitt.edu file transfer utility
env env $ env Display shell environment variables