Lets Make Tech

Useful Commands Every Linux User Should Know

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 http://linuxcommand.org/writing_shell_scripts.php#contents 


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

wget www.website.com/directory/filename.fileextention

Ping a website

ping www.example.com

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.



How to Install Ratpoison Desktop On Ubuntu

If you have been a Linux user for pretty much any amount of time, you know that the desktop environment you use can be changed fairly easily. If you are looking to try a different desktop environment, or decided to add one to a Linux system you are setting up from scratch try Ratpoison. To learn about its history, check out this page.

Ratpoison is made with the goal of killing your mouse. Lets face it, mice are user friendly, but a keyboard (in the right hands) is way more efficient. Ratpoison does not do away with your mouse, you can still use it and all your GUI programs that rely on a mouse. 

Ratpoison allows you to tile your windows into whatever kind of grid you want and re-size them how you please. It also allows you to have other windows up, but out of sight.  

This desktop environment is good if you are working on a lot of code, or using a lot of terminals. 


(This blog started as johnblood.com, seen in the picture above)

First lets install it. 

sudo apt-get install ratpoison

Now lets create a desktop file for it so we can see it at the login screen.

sudo nano /usr/share/xsessions/ratpoison.desktop
[Desktop Entry]
Comment=This session logs you into Ratpoison

Alright, it is all set. Log out, then back in under the Ratpoison desktop

You will be greeted a a friendly welcome instructing you that your esc key is ctrl+t. If you were using ubuntu 14.04, you will still have your old wallpaper. in older versions of ubuntu, you would get a black screen.  \

Hit ctrl+t notice your mouse just changed? Good! Now it is ready for us to send it a command.

Now press c

You should have a terminal now, good job.

Now for some other commands we can do after hitting ctrl+t:


! Run program

. list programs in a menu

w list open windows. Note the corresponding numbers, enter a number after hitting ctrl+t to go to that window. 

n next window

p previous window

a tell the time

k kill

s split horizontal 

S split vertical 

u undo

ctrl+t switch back to the last window

: enter a command 

Commands after : 

quit logs you out

escape set a new escape key eg. escape C-a

bind bind commands to keys eg bind a exec chromium-browser

Save Settings

To keep these settings every time you login, you need to edit .ratpoisonrc in your home folder

# indicates a comment

exec starts a program

bind same usage as bind listed above

echo can be used to make a nice start up message, to disable the existing one with startup_message off

If you are having trouble, check out a few of these resources:


PC Linux OS Magazine

The IT Crow


Home ← Older posts