The linux command line is a powerful interface that when used correctly can save you a great deal of time. I compiled a list of commands to use as a reference sheet.

These commands are powerful and can be used alone or to make BASH scripts that you can set to run automatically with a cron job.

A good reference on how to make a BASH script with these commands 


System manual


Running multiple commands (eg. cd && ls)


Previous Commands

Runs the previous command


View previously executed commands


Print the working directory


Used to display contents of current directory.


Useful options for ls:

Displays all files.


ls -a

Shows links, file, owner, and group.

ls -al 


Goes to the users home directory or a directory specified 

cd /var/www


Used to copy files


Useful options for cp: 

cp -f forces it.
cp -r recursive
cp -s makes a symbolic link
cp -u updates file
cp -i prompt before overwriting
cp -p preserves some traits of file (mode,ownership,timestamps)

Moving files and Syncing
Moves file. /example file.txt /example/newlocation


Program to sync locations 

rsync ~/Documents/server /var/www
Useful options for rsync:
rsync -a ~/Documents/server /var/www a preserves symbolic links and other attributes 
rsync -v ~/Documents/server /var/www verbose
rsync -r ~/Documents/server /var/www recursive 
rsync -z ~/Documents/server /var/www compresses

Finds files

find options:
-iname (ignore case)
-d directory
-f files
-perm 0XXX (replace XXX with permissions
-print prints name
-exec execute a command to files found such as rm

Finds keyword in a file.


Some uses of grep include:
grep 'word' filename
grep 'word' file1 file2 file3
grep 'string1 string2' filename

Find where the files associated with a command are located (replace cd with the command you want)

whereis cd


Reading Files
Display the contents of a file

cat examplefile.txt

Display the last portion of a file (useful for logs)

tail examplefile.txt

**Writing Files**

Update time stamp

touch examplefile.txt

Terminal text editors

nano examplefile.txt
vim examplefile.txt

Echo to location

echo example > example.txt 


Managing Files
Change permissions. Replace the XXX with numbers. The first X is user, the second X is group, the third X is world. 1=execute 2=Write 4=Read. Numbers may be combined.

chmod XXX examplefile.txt


Owner of files

chown owner-user file
chown owner-user:owner-group file
chown owner-user:owner-group directory
chown options owner-user:owner-group file Changes owner and group of a file

Delete files 


useful options with rm:
rm -r 
rm -f

Compare two files 



Get System Info

Useful options: 
-a all
-m machine
-n node
-p processor
-r kernel release
-s kernel name
-v kernel version
-i hardware platform
-o operating system

List devices


Get network information

Useful options for ifconfig:
ifconfig eth0 down disable
ifconfig eth0 up enable
ifconfig eth0 192.168.1.XX Replace XX with desired IP
ifconfig eth0 netmask 255.255.255. change netmask
ifconfig eth0 broadcast change broadcast

Shows uptime 


Shows work load


Shows network activity


Shows memory usage

Useful options for free:
-b bytes
-k kilobytes 
-m megabytes
-g gigabytes

Disk Usage


Directory Size


Show system processes

ps -a


Kill a process (replace 1234 with the pid number by using ps)

kill 1234


If you know the name of the process you can use the following

pkill name_of_process


Start, restart, and stop services

service service_name start
service service_name restart
service service_name stop

Change Password




Shorten the name of commands

alias la='ls -a'

Remove the alias

unalias la



Download a file from the internet


Ping a website


Configure networks


Get MAC address/ip/etc 

ifconfig -a

Follow the packet!

traceroute ip_address_goes_here

tracepath ip_address_goes_here

Packet sniffer


See if ports are open


See what ports are open on a machine


Enable a connection 

ifup eth0

Disable a connection

ifdown eth0

Configure a particular connection


View/Modify routing table



Wild Cards

Stand in for any one unknown character


Stand in for multiple unknown characters 


Wild Card & Regular Expression specify a range of characters

[ ] 


Specify multiple terms

{*.jpg, picture.*}



Escape character if you want the following symbol to be treated as a normal symbol


Regular Expressions 

Stand in for any one unknown character


Regular Expression Match previous symbol zero or more times (stuf* would match stuff and stufff but not stufg)


 Combine the previous to to stand in for multiple unknown characters 


Specifies first line


Specifies end of line






Escape character if you want the following symbol to be treated as a normal symbol


Uppercase letters


Lowercase letters


Alphabetic (letters) meaning upper+lower (both uppercase and lowercase letters)


Numbers in decimal, 0 to 9


Alphanumeric meaning alpha+digits (any uppercase or lowercase letters or any decimal digits)


White space meaning spaces, tabs, newlines and similar


Graphically printable characters excluding space


Printable characters including space


Punctuation characters meaning graphical characters minus alpha and digits


Control characters meaning non-printable characters


Characters that are hexadecimal digits.



Now to really make use of all of this, you will want to learn how to write a BASH shell script. I will be sure to get a tutorial up soon on how to make your first BASH script.