L
C

OMMAND 
C
INUX 
HEET 
S
HEAT 

L

INE 

A

 Q

UICK 

R

EFERENCE 

G

UIDE from: 

LinuxTrainingAcademy.com 

https://www.LinuxTrainingAcademy.com 

 
​
​
​
​
​
​
​
​
 
​
​
​
​
​
​
 
 
 
 
 
Table of Contents 

1 - SYSTEM INFORMATION

2 - HARDWARE INFORMATION

3 - PERFORMANCE MONITORING AND STATISTICS

4 - USER INFORMATION AND MANAGEMENT

5 - FILE AND DIRECTORY COMMANDS

6 - PROCESS MANAGEMENT

7 - FILE PERMISSIONS

8 - NETWORKING

9 - ARCHIVES (TAR FILES)

10 - INSTALLING PACKAGES

11 - SEARCH

12 - SSH LOGINS

13 - FILE TRANSFERS

14 - DISK USAGE

15 - DIRECTORY NAVIGATION

2 

2 

3 

3 

4 

5 

5 

6 

6 

7 

7 

7 

8 

8 

8 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com 

1 

 
 
 
 
 
 
 
 
1 - SYSTEM INFORMATION 

uname -a 

uname -r 

# Display Linux system information 

# Display kernel release information 

cat /etc/redhat-release 

# Show which version of redhat installed 

uptime 

hostname 

hostname -I 

last reboot 

date 

cal 

w 

whoami 

# Show how long the system has been running + load 

# Show system host name 

# Display the IP addresses of the host 

# Show system reboot history 

# Show the current date and time 

# Show this month's calendar 

# Display who is online 

# Who you are logged in as 

2 - HARDWARE INFORMATION 

dmesg 

# Display messages in kernel ring buffer 

cat /proc/cpuinfo 

# Display CPU information 

cat /proc/meminfo 

# Display memory information 

free -h 

lspci -tv 

lsusb -tv 

dmidecode 

# Display free and used memory ( 
-m

 for GB.) 

 for MB, 

-g

-h

 for human readable, 

# Display PCI devices 

# Display USB devices 

# Display DMI/SMBIOS (hardware info) from the BIOS 

hdparm -i /dev/sda 

# Show info about disk sda 

hdparm -tT /dev/sda 

# Perform a read speed test on disk sda 

badblocks -s /dev/sda 

# Test for unreadable blocks on disk sda 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  2 

 
 
 
 
​
​
​
​
​
 
 
 
 
 
3 - PERFORMANCE MONITORING AND STATISTICS 

top 

htop 

mpstat 1 

vmstat 1 

iostat 1 

# Display and manage the top processes 

# Interactive process viewer (top alternative) 

# Display processor related statistics 

# Display virtual memory statistics 

# Display I/O statistics 

tail 100 /var/log/messages 

# Display the last 100 syslog messages  (Use 
/var/log/syslog

 for Debian based systems.) 

tcpdump -i eth0 

# Capture and display all packets on interface eth0 

tcpdump -i eth0 'port 80' 

# Monitor all traffic on port 80 ( HTTP ) 

lsof 

# List all open files on the system 

lsof -u user 

# List files opened by 

user 

free -h 

# Display free and used memory ( -h for human 
readable, -m for MB, -g for GB.) 

watch df -h 

# Execute "df -h", showing periodic updates 

4 - USER INFORMATION AND MANAGEMENT 

id 

last 

who 

w 

# Display the user and group ids of your 
current user. 

# Display the last users who have logged onto 
the system. 

# Show who is logged into the system. 

# Show who is logged in and what they are 
doing. 

groupadd test 

# Create a group named "test". 

useradd -c "John Smith" -m john 

# Create an account named john, with a 
comment of "John Smith" and create the user's 
home directory. 

userdel john 

# Delete the john account. 

usermod -aG sales john 

# Add the john account to the sales group 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  3 

 
​
​
 
 
 
 
5 - FILE AND DIRECTORY COMMANDS 

ls -al 

pwd 

# List all files in a long listing (detailed) format 

# Display the present working directory 

mkdir directory 

# Create a directory 

rm file 

rm -r directory 

rm -f file 

# Remove (delete) file 

# Remove the directory and its contents 
recursively 

# Force removal of file without prompting for 
confirmation 

rm -rf directory 

# Forcefully remove directory recursively 

cp file1 file2 

# Copy file1 to file2 

cp -r source_directory 
destination 

mv file1 file2 

source_directory

 recursively to 

# Copy 
destination
source_directory
otherwise create 
contents of 

. If destination exists, copy 
destination
 with the 

 into 
destination

, 

source_directory

. 

# Rename or move 
file1
an existing directory, move file1 into directory 
file2 

file2

. If file2 is 

 to 

ln -s /path/to/file linkname 

# Create symbolic link to 

linkname 

touch file 

cat file 

less file 

head file 

tail file 

tail -f file 

# Create an empty file or update the access 
and modification times of file. 

# View the contents of 

file 

# Browse through a text file 

# Display the first 10 lines of 

file 

# Display the last 10 lines of 

file 

# Display the last 10 lines of 
the file as it grows. 

file

 and "follow" 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  4 

 
 
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
 
 
 
 
 
6 - PROCESS MANAGEMENT 

ps 

ps -ef 

# Display your currently running processes 

# Display all the currently running processes on the 
system. 

ps -ef | grep processname 

# Display process information for 

processname 

top 

htop 

# Display and manage the top processes 

# Interactive process viewer (top alternative) 

kill pid 

# Kill process with process ID of p

id 

killall processname 

# Kill all processes named 

processname 

program & 

# Start 

program

 in the background 

bg 

fg 

fg n 

# Display stopped or background jobs 

# Brings the most recent background job to 
foreground 

# Brings job 

n

 to the foreground 

7 - FILE PERMISSIONS 

        PERMISSION      EXAMPLE 

         U   G   W 
        rwx rwx rwx     chmod 777 filename  # Use sparingly! 
        rwx rwx r-x     chmod 775 filename 
        rwx r-x r-x     chmod 755 filename 
        rw- rw- r--     chmod 664 filename 
        rw- r-- r--     chmod 644 filename 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  5 

 
 
​
​
​
​
​
​
​
 
 
 
 
 
 
 
 
 
        LEGEND 

        U = User  
        G = Group  
        W = World 

        r = Read 
        w = write 
        x = execute  
        - = no access 

8 - NETWORKING 

ifconfig -a 

# Display all network interfaces and ip address 

ifconfig eth0 

# Display eth0 address and details 

ethtool eth0 

ping host 

# Query or control network driver and hardware settings 

# Send ICMP echo request to 

host 

whois domain 

# Display whois information for 

domain 

dig domain 

# Display DNS information for 

domain 

dig -x IP_ADDRESS 

# Reverse lookup of 

IP_ADDRESS 

host domain 

hostname -i 

hostname -I 

# Display DNS ip address for 

domain 

# Display the network address of the host name. 

# Display all local ip addresses 

wget http://domain.com/file  # Download 

http://domain.com/file 

netstat -nutlp 

# Display listening tcp and udp ports and corresponding 
programs 

9 - ARCHIVES (TAR FILES) 

tar cf archive.tar directory 

# Create tar named 
directory

. 

archive.tar

 containing 

tar xf archive.tar 

# Extract the contents from 

archive.tar

. 

tar czf archive.tar.gz directory  # Create a gzip compressed tar file name 

archive.tar.gz

. 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  6 

 
 
 
 
​
​
​
​
​
​
 
 
​
​
​
​
​
​
 
 
tar xzf archive.tar.gz 

# Extract a gzip compressed tar file. 

tar cjf archive.tar.bz2 directory  # Create a tar file with bzip2 compression 

tar xjf archive.tar.bz2 

# Extract a bzip2 compressed tar file. 

10 - INSTALLING PACKAGES 

yum search keyword 

# Search for a package by 

keyword

. 

yum install package 

# Install 

package

. 

yum info package 

rpm -i package.rpm 

# Display description and summary information 
about 

package

. 

# Install package from local file named 
package.rpm 

yum remove package 

# Remove/uninstall 

package

. 

tar zxvf sourcecode.tar.gz 
cd sourcecode 
./configure 
make 
make install 

# Install software from source code. 

11 - SEARCH 

grep pattern file 

# Search for 

pattern

 in 

file 

grep -r pattern directory 

# Search recursively for 

pattern

 in 

directory 

locate name 

# Find files and directories by name 

find /home/john -name 
'prefix*' 

# Find files in 

/home/john

 that start with "prefix". 

find /home -size +100M 

# Find files larger than 100MB in /home 

12 - SSH LOGINS 

ssh host 

# Connect to 

host

 as your local username. 

ssh user@host 

# Connect to 

host

 as 

user 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  7 

 
 
​
​
​
​
​
​
​
​
 
 
​
​
​
​
​
​
​
​
 
 
​
​
​
​
​
 
 
ssh -p port user@host 

# Connect to 

host

 using 

port 

13 - FILE TRANSFERS 

scp file.txt server:/tmp 

# Secure copy 
server 

file.txt 

to the /tmp folder on 

scp server:/var/www/*.html /tmp  # Copy 

*.html

 files from 

server

 to the local 

/tmp folder. 

scp -r server:/var/www /tmp 

# Copy all files and directories recursively from 
server

 to the current system's /tmp folder. 

rsync -a /home /backups/ 

# Synchronize 

/home

 to

 /backups/home 

rsync -avz /home 
server:/backups/ 

# Synchronize files/directories between the local 
and remote system with compression enabled 

14 - DISK USAGE 

# Show free and used space on mounted filesystems 

# Show free and used inodes on mounted filesystems 

# Display disks partitions sizes and types 

# Display disk usage for all files and directories in 
human readable format 

# Display total disk usage off the current directory 

15 - DIRECTORY NAVIGATION 

# To go up one level of the directory tree.  (Change into 
the parent directory.) 

# Go to the $HOME directory 

# Change to the /etc directory 

df -h 

df -i 

fdisk -l 

du -ah 

du -sh 

cd .. 

cd 

cd /etc 

LINUX COMMAND LINE CHEAT SHEET         

​https://www.LinuxTrainingAcademy.com  8 

​
​
​
 
 
​
​
​
​
​
​
​
​
​
​
 
 
 
 
 
 
 
