Linux Command Line Cheat Sheet

To supplement the courses in our Cyber Security ​Career Development Platform, here is a Linux Command Line Cheat Sheet.

You may download the PDF version of this cheat sheet here.

System Information

uname -aDisplay Linux system information
uname -rDisplay kernel release information
cat /etc/redhat-releaseShow which version of redhat installed
uptimeShow how long the system has been running + load
hostnameShow system host name
hostname -IDisplay the IP addresses of the host
last rebootShow system reboot history
dateShow the current date and time
calShow this month’s calendar
wDisplay who is online
whoamiWho you are logged in as

Hardware Information

dmesgDisplay messages in kernel ring buffer
cat /proc/cpuinfoDisplay CPU information
cat /proc/meminfoDisplay memory information
free -hDisplay free and used memory ( -h for human readable, -m for MB, -g for GB.)
lspci -tvDisplay PCI devices
lsusb -tvDisplay USB devices
dmidecodeDisplay DMI/SMBIOS (hardware info) from the BIOS
hdparm -i /dev/sdaShow info about disk sda
hdparm -tT /dev/sdaPerform a read speed test on disk sda
badblocks -s /dev/sdaTest for unreadable blocks on disk sda

Performance Monitoring And Statistics

topDisplay and manage the top processes
htopInteractive process viewer (top alternative)
mpstat 1Display processor related statistics
vmstat 1Display virtual memory statistics
iostat 1Display I/O statistics
tail 100 /var/log/messagesDisplay the last 100 syslog messages (Use/var/log/syslog for Debian based systems.)
tcpdump -i eth0Capture and display all packets on interface eth0
tcpdump -i eth0 ‘port 80’Monitor all traffic on port 80 (HTTP)
lsofList all open files on the system
lsof -u userList files opened by user
free -hDisplay free and used memory ( -h for human readable, -m for MB, -g for GB.)
watch df -hExecute “df -h”, showing periodic updates

User Information And Management

idDisplay the user and group ids of your current user.
lastDisplay the last users who have logged onto the system.
whoShow who is logged into the system.
wShow who is logged in and what they are doing.
groupadd testCreate a group named “test”.
useradd -c “John Smith” -m johnCreate an account named john, with a comment of “John Smith” and create the user’s home directory.
userdel johnDelete the john account.
usermod -aG sales johnAdd the john account to the sales group

File And Directory Commands

ls -alList all files in a long listing (detailed) format
pwdDisplay the present working directory
mkdir directoryCreate a directory
rm fileRemove (delete) file
rm -r directoryRemove the directory and its contents recursively
rm -f fileForce removal of file without prompting for confirmation
rm -rf directoryForcefully remove directory recursively
cp file1 file2Copy file1 to file2
cp -r source_directory destinationCopy source_directory recursively to destination . If destination exists, copy source_directory into destination , otherwise create destination with the contents of source_directory .
mv file1 file2Rename or move file1 to file2 . If file2 is an existing directory, move file1 into directory file2
ln -s /path/to/file linknameCreate symbolic link to linkname
touch fileCreate an empty file or update the access and modification times of file.
cat fileView the contents of file
less fileBrowse through a text file
head fileDisplay the first 10 lines of file
tail fileDisplay the last 10 lines of file
tail -f fileDisplay the last 10 lines of file and “follow” the file as it grows.

Process Management

psDisplay your currently running processes
ps -efDisplay all the currently running processes on the system.
ps -ef | grep processnameDisplay process information for processname
topDisplay and manage the top processes
htopInteractive process viewer (top alternative)
kill pidKill process with process ID of pid
killall processnameKill all processes named processname
program &Start program in the background
bgbg # Display stopped or background jobs
fgBrings the most recent background job to foreground
fg nBrings job n to the foreground

File Permissions

Linux File Permissions
U    G    WU = User
rwx rwx rwxchmod 777 filename # Use sparingly!G = Group
rwx rwx r-xchmod 775 filenameW = World
rwx r-x r-xchmod 755 filenamer = Read
rw- rw- r–chmod 664 filenamew = write
rw- r– r–chmod 644 filenamex = execute
Linux File Permissions Cheat Sheet– = no access


ifconfig -aDisplay all network interfaces and ip address
ifconfig eth0Display eth0 address and details
ethtool eth0Query or control network driver and hardware settings
ping hostSend ICMP echo request to host
whois domainDisplay whois information for domain
dig domainDisplay DNS information for domain
dig -x IP_ADDRESSReverse lookup of IP_ADDRESS
host domainDisplay DNS ip address for domain
hostname -iDisplay the network address of the host name.
hostname -IDisplay all local ip addresses
netstat -nutlpDisplay listening tcp and udp ports and corresponding programs

Archives (TAR Files)

tar cf archive.tar directoryCreate tar named archive.tar containing directory .
tar xf archive.tarExtract the contents from archive.tar .
tar czf archive.tar.gz directoryCreate a gzip compressed tar file name archive.tar.gz .
tar xzf archive.tar.gzExtract a gzip compressed tar file.
tar cjf archive.tar.bz2 directoryCreate a tar file with bzip2 compression
tar xjf archive.tar.bz2Extract a bzip2 compressed tar file.

Installing Packages

yum search keywordSearch for a package by keyword .
yum install packageInstall package .
yum info packageDisplay description and summary information about package .
rpm -i package.rpmInstall package from local file named package.rpm
yum remove packageRemove/uninstall package .
tar zxvf sourcecode.tar.gzcd sourcecode./configuremakemake installInstall software from source code.


grep pattern fileSearch for pattern in file
grep -r pattern directorySearch recursively for pattern in directory
locate nameFind files and directories by name
find /home/john -name’prefix*’Find files in /home/john that start with “prefix”.
find /home -size +100MFind files larger than 100MB in /home

SSH Logins

ssh hostConnect to host as your local username.
ssh user@hostConnect to host as user
ssh -p port user@hostConnect to host using port

File Transfers

scp file.txt server:/tmpSecure copy file.txt to the /tmp folder on server
scp server:/var/www/*.html /tmpCopy *.html files from server to the local /tmp folder.
scp -r server:/var/www /tmpCopy 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 /homeserver:/backups/Synchronize files/directories between the local and remote system with compression enabled

Disk Usage

df -hShow free and used space on mounted filesystems
df -iShow free and used inodes on mounted filesystems
fdisk -lDisplay disks partitions sizes and types
du -ahDisplay disk usage for all files and directories in human readable format
du -shDisplay total disk usage off the current directory

Directory Navigation

cd ..To go up one level of the directory tree. (Change into the parent directory.)
cdGo to the $HOME directory
cd /etcChange to the /etc directory
  • John Prevost says:

    Thank you Nathan. It’s very useful

  • Johnny Boy says:

    Brilliant. I was just looking for something like this!

  • Gonno says:


  • Aldo says:

    Great information, thanks Nathan!

  • Pavan says:

    Thanks for the information Nathan

  • Franklin says:

    You are awesome brother. Thanks

  • Harry says:

    Thank you Very Much. This is very helpful to us.

  • Marc says:

    Thanks, very helpful! Minor improvement, in section 11 of the PDF version there is a line-break glitch, command and explanation mismatch after line 2.

  • Bernardo says:

    It’s really very useful! Many thanks from Mozambique…

  • Josè says:

    Thanks a lot Nathan

  • Raja says:

    Helpful for us to enhance our knowledge.. keep it

  • Joe says:

    Love all these cheat sheets you have been sending through. They really come in handy. Thanks

  • Karl Obayi says:

    Thanks for Sharing. Great resource.

  • LYDIA says:

    Thanks very much. this is very great and clear and easier to go through

  • Mohit says:


  • Alishia says:

    Hello Nathan, thanks for sharing this Linux commandline cheat sheet, it will be really helpful for cybersecurity enthusiasts.

  • ShahidTech says:

    Shouldn’t the table row under permission have U G O instead of
    U G W?

  • Edwin dus says:

    You’re the best.
    Your cheat sheets are great!

  • Troy Williams says:

    Just what i was looking for really appreciate you sharing this…

  • Aboubacar Sakho says:

    This is so excellent! I am really enjoying this news letters. You are simply the best. I am inviting many friend from my master program to join your classes.


    Thank you sir

  • Nick says:

    Awesome thanks so much, cant wait to play around with these and learn so many new ones too 🙂

  • Abdul Latheef says:

    Excellent, thanks for sharing, superb..

  • Luis Reales says:

    Thank you so much, awesome work!

  • >