Linux Commands Cheat Sheet

Here in this cheat sheet, Linux commands are categorized into different sections according to its usage. We have designed all the commands in a nice background color.

I have added had both pdf and image (png) format of the cheat sheet.

Cheat sheet

Download your linux commands cheat sheet in pdf format and please keep us posted if you have any suggestions or if you find any command that we missed out.

If you are looking to print Linux commands cheat sheet in A4 size paper its available for download.

Linux Commands Cheat Sheet

1) System

uname  Displays  Linux system information
uname -rDisplays  kernel release information
uptimeDisplays how long the system has been running including load average
hostnameShows the system hostname
hostname -iDisplays the IP address of the system
last rebootShows system reboot history
dateDisplays current system date and time
timedatectlQuery and change the System clock
calDisplays the current calendar month and day
wDisplays currently  logged in users in the system
whoamiDisplays who you are logged in as
finger usernameDisplays information about the user

2) Hardware

dmesgDisplays bootup messages
cat /proc/cpuinfoDisplays more information about CPU e.g model, model name, cores, vendor id
cat /proc/meminfoDisplays more information about hardware memory e.g. Total and Free memory
lshwDisplays information about system's hardware configuration
lsblkDisplays block devices related information
free -mDisplays free and used memory in the system (-m flag indicates memory in MB)
lspci -tvDisplays PCI devices in a tree-like diagram
lsusb -tvDisplays USB devices in a tree-like diagram
dmidecodeDisplays hardware information from the BIOS
hdparm -i /dev/xdaDisplays information about disk data
hdparm -tT /dev/xda <:code>Conducts a read speed test on device xda
badblocks -s /dev/xdaTests  for unreadable blocks on disk

3) Users

idDisplays the details of the active user e.g. uid, gid, and groups
lastShows the last logins in the system
whoShows who is logged in to the system
groupadd "admin" Adds the group 'admin'
adduser "Sam" Adds user Sam
userdel "Sam"Deletes user Sam
usermodUsed for changing / modifying user information

4) File Commands

ls -alLists files - both regular &  hidden files and their permissions as well.
pwdDisplays the current directory file path
mkdir 'directory_name'Creates a new directory
rm file_name Removes a file
rm -f filenameForcefully removes a file
rm -r directory_nameRemoves a directory recursively
rm -rf directory_nameRemoves a directory forcefully and recursively
cp file1 file2Copies the contents of file1 to file2
cp -r dir1 dir2Recursively Copies dir1 to dir2. dir2 is created if it does not exist
mv file1 file2Renames file1 to file2
ln -s /path/to/file_name   link_nameCreates a symbolic link to file_name
touch file_nameCreates a new file
cat > file_namePlaces standard input into a file
more file_nameOutputs the contents of a file
head file_nameDisplays the first 10 lines of a file
tail file_nameDisplays the last 10 lines of a file
gpg -c file_nameEncrypts a file
gpg file_name.gpgDecrypts a file
wcPrints the number of bytes, words and lines in a file
xargsExecutes commands from standard input

5) Process Related

psDisplay currently active processes
ps aux | grep 'telnet'Searches for the id of the process 'telnet'
pmapDisplays memory map of processes
top Displays all running processes
kill pidTerminates process with a given pid
killall procKills / Terminates all processes named proc
pkill process-nameSends a signal to a process with its name
bgResumes suspended jobs in the background
fgBrings suspended jobs to the foreground
fg n job n to the foreground
lsofLists files that are open by processes
renice 19 PIDmakes a process run with very low priority
pgrep firefoxfind Firefox process ID
pstreevisualizing processes in tree model

6) File Permission

chmod octal filename         Change file permissions of the file to octal
chmod 777 /data/test.c       Set rwx permissions to owner, group and everyone (everyone else who has access to the server)
chmod 755 /data/test.c       Set rwx to the owner and r_x to group and everyone
chmod 766 /data/test.c       Sets rwx for owner, rw for group and everyone
chown owner user-file         Change ownership of the file
chown owner-user:owner-group file_name       Change owner and group owner of the file
chown owner-user:owner-group directory  Change owner and group owner of the directory

7) Network

ip addr show                   Displays IP addresses and all the network interfaces
ip address add dev eth0    Assigns IP address to interface eth0
ifconfig                             Displays IP addresses of all network interfaces
ping  host                       ping command sends an ICMP echo request to establish a connection to server / PC
whois domain                  Retrieves more information about a domain name
dig domain                       Retrieves DNS information about the domain
dig -x host                    Performs reverse lookup on a domain
host          Performs an IP lookup for the domain name
hostname -i                     Displays local IP address
wget file_name             Downloads a file from an online source
netstat -pnltu     Displays all active listening ports

8) Compression/Archives

tar -cf home.tar home<:code>Creates archive file called 'home.tar' from file 'home'
tar -xf files.tar              Extract archive file 'files.tar'
tar -zcvf home.tar.gz source-folder    Creates gzipped tar archive file from the source folder
gzip file Compression a file with .gz extension

9) Install Packages

rpm -i pkg_name.rpm            Install an rpm package
rpm -e pkg_name                     Removes an rpm package
dnf install pkg_nameInstall package using dnf utility

10) Install Source (Compilation)

./configureChecks your system for the required software needed to build the program. It will build the Makefile containing the instructions required to effectively build the project
makeIt reads the Makefile to compile the program with the required operations. The process may take some time, depending on your system and the size of the program
make installThe command installs the binaries in the default/modified paths after the compilation

11) Search

grep 'pattern' files                           Search for a given pattern in files
grep -r pattern dir                             Search recursively for a pattern in a given directory
locate file                                            Find all instances of the file
find /home/ -name "index"              Find file names that begin with 'index' in /home folder
find /home -size +10000kFind files greater than 10000k in the home folder

12) Login

ssh user@host                                        Securely connect to host as user
ssh -p port_number user@host      Securely connect to host using a specified port
ssh host                                                Securely connect to the system via SSH default port 22
telnet host Connect to host via telnet default port 23

13) File Transfer

scp file1.txt server2/tmp           Securely copy file1.txt to server2 in /tmp directory
rsync -a /home/apps  /backup/ Synchronize contents in /home/apps directory with /backup  directory

14) Disk Usage

df  -h                           Displays free space on mounted systems
df  -i                          Displays free inodes on filesystems
fdisk  -l                    Shows disk partitions, sizes, and types
du  -sh                        Displays disk usage in the current directory in a human-readable format
findmnt                      Displays target mount point for all filesystems
mount device-path mount-pointMount a device

15) Directory Traverse

cd ..             Move up one level in the directory tree structure
cd                 Change directory to $HOME directory
cd /test Change directory to /test directory

Read Also:

46 Comments... add one

  1. Wow, very good idea, this cheat-sheet is very nice to have under the keyboard.
    Seeing forward for more commands on this sheet.

    • Hi Paul, thanks for sharing your ideas. Many users use different frequency based on their specific job. Alphabetical order will not likely help specific requirement. "Order of like" suggestion is good idea :-)

    • I really like the layout of this Paul. I am just learning linux and trying to learn some commands. If I wanted to put a link in a file directory or delete a directory then trying to find it alphabetically would be hard since I don't know the command I am looking for. Also the poster is right. Which commands someone uses most often depends upon what they usually work with. If I know I want to change a directory or file I can just look into the appropriate category.

  2. How about moving sections like system and hardware far away from the top and sticking to commonly used but harder to remember sections like process, install from package etc near the top.

    Nice sheet.

  3. I use just about all these commands, and more; only thing I learned is that should really be using hostname -i more often instead of scanning through ifconfig -a for my IP. :)

    Also wanted to point at an error in your cheat sheet:

    "bg" does not "Lists stopped or background jobs"; it puts the most recent job in the background (ctrl-z then bg). It's "jobs" that lists 'em (which I always have aliased to just "j").

    • @Craig Yes will design a wallpaper sketch. There are few minor errors on the cheat sheet , once I correct all then I will do

  4. Hi Bobbin,

    I came back to see if you'd fixed the error I pointed out on your cheat sheet, but instead I see that not only was it not fixed, but my comment pointing it was DELETED. Why? I'm not wrong.

    To be clear - The ERROR above is that "bg" does NOT "list stopped or background jobs"; the "jobs" command does that. "bg" puts the most recent job in the background.

    • Hi Jason, You are 100% correct. I am really thankful for pointing out this. I really saw your comments other day. Please give me couple days , I will change it on infograph. I have already changed on the html page(detailed command page).

  5. There's a typo in the chart:

    In the File Permission related section: #chmod 755 sets rwx for owner, r_x for group and world. #chmod 766 would sets rwx for owner, rw for group and world

  6. The only MAJOR problem I have with this so far is that the page clearly states at the top that this page is 'supposed' to be for the Black & White version of the Cheatsheet, however the .pdf file linked to is for the Color version. And the cheatsheet image itself is the color version as well. So where do we actually get the Black & White version from?

  7. Ok, I'll ask again since my post was apparently deleted. Why is this page titled "Linux Commands Cheat Sheet in Black & White" when only the color version is supplied as a .pdf and the image shown is the color version. I'd like to download the BLACK & WHITE .pdf version, not the color .pdf one, not the color .png one, but yes the BLACK & WHITE version. (if you're not going to provide the Black & White version on a page that is clearly labeled as being for the Black & White version then the least you can do is change the name of the page to reflect that fact!!!)

    • Hi Edwin , thanks for the comments. Let me see if I can get black & white version. Other option would be print document in black & white ink then scan the document to pdf version

  8. A cool idea but I have some suggestions;

    1) How about adding package managers other then rpm (apt-get at least, since most Linux n00bs will be using Debian-based distros)

    2) Could you provide us with source files so anyone can make translated versions of the infographic and submi it back here?


  9. It would be really really helpful to have a true black & white version. The color version is very nice, but not all printers handle pdf color inversion correctly. Excellent work collecting this useful cheat-sheet.

    • Thanks Scott,

      net-tools are no longer maintained and become obsolete. As you mentioned, the replacement for netstat is ss.


Leave a Comment