UNIX Commands Cheat Sheet

, , , ,
  • Digg
  • Technorati
  • del.icio.us
  • Propeller
  • StumbleUpon
  • Reddit
  • Mixx
  • Fark
  • Slashdot
  • Sphinn
  • Design Float
  • DZone
  • BlinkList
  • email
November 26th, 2008 | Web Development How-to's | 3 Comments

If you develop websites and do not use a UNIX prompt, you are at a major disadvantage to those that do. Knowing your way around a UNIX command line allows you to accomplish more in a shorter period of time and often offers a better way to manipulate, edit, and work with files on your server.

Whether you are a beginner developer or a seasoned professional, you know that keeping every command and syntax in your head is impossible. To make life easier I compiled the following list of common UNIX commands as guide.

* NOTE: See below for list of abbreviations used in this guide.

Output, Communication, & Help

Command Description
lpr -P printer f Output file f to line printer
script [f] Save terminal session to f
exit Stop saving terminal session
mail username Send mail to user
biff [y/n] Instant notification of mail
man name UNIX manual entry for name
learn Online tutorial

Environment Status

Command Description
ls [d] [f...] List files in directory
ls -1 [f...] List files in detail
alias [name] Display command aliases
printenv [name] Print environment values
quota Display disk quota
date Print date & time
who List logged in users
whoami Display current user
finger [username] Output user information
chfn Change finger information
pwd Print working directory
history Display recent commands
! n Submit recent command n

Environment Control

Command Description
cd d Change to directory d
mkdir d Create new directory d
rmdir d Remove directory d
mv f1 [f2...] d Move file f to directory d
mv d1 d2 Rename directory d1 as d2
passwd Change password
alias name1 name2 Create command alias
unalias name1 Remove command alias name1
rlogin nd Login to remote node
logout End terminal session
setenv name v Set env var to value v
unsetenv name1 [name2...] Remove environment variable

Process Control

Command Description
Ctrl/c * Interrupt processes
Ctrl/s * Stop screen scrolling
Ctrl/q * Resume screen output
sleep n Sleep for n seconds
jobs Print list of jobs
kill [%n] Kill job n
ps Print process status stats
kill -9 n Remove process n
Ctrl/z * Suspend current process
stop %n Suspend background job n
command& Run command in background
bg [%n] Resume background job n
fg [%n] Resume foreground job n
exit Exit from shell

File Manipulation

Command Description
vi [f] Vi fullscreen editor
emacs [f] Emacs fullscreen editor
ed [f] Text editor
wc f Line, word, & char count
cat f List contents of file
more f List file contents by screen
cat f1 f2 > f3 Concatenates f1 & f2 into f3
chmod mode f Change protection mode of f
cmp f1 f2 Compare two files
cp f1 f2 Copy file f1 into f2
sort f Alphabetically sort f
split [-n] f Split f into n-line pieces
mv f1 f2 Rename file f1 as f2
rm f Delete (remove) file f
grep ‘ptn’ f Outputs lines that match ptn
diff f1 f2 Lists file differences
head f Output beginning of f
tail f Output end of f

Abbreviations

Abbreviation Description
d directory
d directory
env environment
f filename
n number
nd computer node
var variable
[y/n] yes or no
[] optional arg
list

If you have some other good examples that you use often and think should be a part of this resource, let me know about them in the comments below.

Welcome Back!

Now is your chance to join our growing community! Be the first to know about great new articles like this one. Register for my Email Updates or RSS Feed today!

About the Author

Zach is a marketing consultant and owner of a FL web design and marketing group. He offers graphic design and marketing services, speaks on Internet marketing, and blogs about it all in his free time. (ยป)

Contact Zach: Company Website | Email

Related Posts


Multiple WordPress Sidebars

htaccess Cheatsheet

Google’s SEO Starter Guide

Optimizing Word Press Title Tags

As seen on CSS Mania…


3 Comments

  1. mySelf

    November 27, 2008 @ 2:30 am

    Nice listing. An printable PDF Version would be nice :)

    Reply

  2. SeanJA

    November 27, 2008 @ 5:33 am

    … is an abbreviation for ls? That is backwards…

    wall: send message to everybody’s terminal

    Reply

    zacheos

    As in the example: “unsetenv name1 [name2...]”

    I used the “…” to represent the ability to create a long list of files in one command, such as: “unsetenv name1 name2 name3 name4 etc…”

    Reply

RSS feed Comments | TrackBack URI

Write Comment