(Updated 2011 Oct 16)
Basic Unix Commands
The basics:
commands are generally of the form: command -optional_flags argument(s)
for more information on any command, type: man command_name
examples are denoted with open bullets
cd -- change directory
cd tmp_directory -- changes to directory named tmp_directory
cd demo/img -- equivalent to cd demo followed by cd img
cd -- go to own home directory
cd ~phodis -- go to phodis's home directory
cd .. -- changes to directory one level up
cp -- copy
cp file1 file2 -- copies file1 to file2
cp stuff* tmp_directory/ -- copies files starting with stuff to directory tmp_directory
df -- disk free
df -- shows status of all accessible disks
df . -- shows status of the disk you're on
df /usr50 -- shows status of disk named /usr50
du -- disk usage
du -- shows, in blocks, usage of current directory and all subdirectories
du -k -- shows, in kilobytes, usage of current directory and all subdirectories
gzip/gunzip -- compresses/uncompresses files
gzip *.mrc -- compresses files ending with .txt
gunzip *.mrc.gz -- uncompresses gzipped files
jot -- a bare-bones text editor (on SGIs)
jot list.txt -- opens list.txt and creates it if it doesn't exist
lpq -- show printer queue
lpq -Prose4 -- shows queue for printer named rose4
lpr -- send file to printer
lpr -Prose4 *.txt -- prints all files ending in .txt to printer rose4
ls -- list directory
ls -- lists current directory
ls tmp -- lists file or subdirectory named tmp
ls *.txt -- lists files ending with .txt
ls -l -- lists long format, including files size, date modified, file protection, etc.
ls -t -- lists files in chronological order, most recent files first
ls -S -- lists files in order of size, largest first
ls -r -- lists files in reverse order
ls -F -- appends filetype indicators (e.g., executable, link, etc.)
I usually alias ls to this, and to override it, add --indicator-style=none
ls -ltr -- lists files in long format in reverse chronological order
mkdir -- make directory
mkdir tmp_directory -- creates directory branching from current directory
more -- looks at a file, generally a text file
more list.txt -- outputs contents of list.txt to the screen
mv -- move/rename
mv file1 tmp_directory/ -- moves file1 to directory tmp_directory
mv file1 file2 -- renames file1 to file2
pwd -- print working directory
rm -- remove/delete
rm list.txt -- deletes the file list.txt
rm *.txt -- deletes all files in directory ending in '.txt' (be careful with this one)
rm -r tmp_directory -- removes directory tmp_directory and its contents
which -- finds directory location of accessible executables
which xv -- would give the response: /sware/xv/xv
This page is Lynx-enhanced.