Linux Commands Cheat Sheet by Category

In this tutorial, we’ll show you a mated list of the most useful Linux commands cheatsheet. This are some of the more useful commands, but they aren’t easy for everyone to remember.
linux commands cheatsheet
Did you know that there are verbally hundreds of Linux commands? Even on a simple installation of a Linux server, there are easily over 1,000 different commands. The interesting thing is that most people only need to use a very small subset of this commands. Below is a Linux “cheat sheet” that breaks down some of the more commonly used commands by category.

This cheat sheet offers a number of commands that you can use for quick reference. I have prepared this Linux commands cheat sheet as a quick reference for advanced and basic users.

Also Read: How To Install Notepad++ In Ubuntu ( Linux )

Basic Linux Commands CheatSheet

In this section, we will show you some basic Linux commands with examples.

dateDisplay the current system date and time
hostnamectlGet system information including, operating system, kernel, and release version
hostnameDisplay the hostname of the system
free -mScreen free and used memory in the system
topDisplay all running processes
lsList all files and directories in the current working directory
ifconfigDisplay the IP and Mac Address of the system
wDisplay currently logged in users in the system
ls -alList all files and directories including, hidden files and other information like permissions, size, and owner
cdChange the directory to the home directory
cd ..Change the directory to one level up
rebootRestart the system
cat filenameDisplay the content of the file
mv oldfile newfileRename a file
rm filenameDelete a file
mkdir dirnameCreate a directory
rm -rf dirnameRemove a directory
historyPrint a history list of all commands
cat file1 file2 > file3Combine two files named file1 and file2 and store the output in a new file file3
tail filenameDisplay the last 10 lines of a file
head filenameDisplay the first 10 lines of a file
clearClear the terminal
shutdown -h nowShut down the system

File Permission Commands

chmod 777 filenameAssign full(read, write, and execute) permission to everyone
ls -l filenameCheck the current permission of any file
chmod -R 777 dirnameAssign full permission to the directory and all sub-directories
chmod 766 filenameAssign full permission to the owner, and read and write permission to group and others
chown -R user:group dirnameChange the owner and group ownership of the directory and all sub-directories
chmod -x filenameRemove the execution permission of any file
chown username filenameChange the ownership of a file
chown user:group filenameChange the owner and group ownership of a file

Networking Commands

ip addr add IP-Address dev eth1Add a temporary IP address to interface eth1
ip addr show Or ifconfigList all IP addresses and network interfaces
netstat -pnltuDisplay all listening port
whois domainnameDisplay more information about any domain
host domainnamePerform an IP lookup for a domain
ping host-ipCheck connectivity between two hosts
dig -x IP-AddressPerform a reverse lookup of an IP address
dig domainnameDisplay DNS information of any domain
dig -x domainamePerform a reverse lookup on domain

User and Group Management Commands

Linux is a multi-user operating system. Therefore, multiple users can log into the system and work on the system at the same time. In some cases, two or more users may need to share access to system resources such as files and directories. In this case, managing users and groups allows you to achieve your goals.

wDisplay all login users
useradd usernameAdd a new user account
userdel -r usernameDelete a user account
idDisplay UID and GID of the current user
usermod [option] usernameChange the user account information including, group, home directory, shell, expiration date
usermod -aG groupname usernameAdd a user to a specific group
groupadd groupnameCreate a new group
groupdel groupnameRemove a group
lastDisplay information of the last login user

Process Management Commands

When to run an application on Linux. The application will receive a process ID or PID. Process Management helps you monitor and manage your application.

ps -ef | grep processnameDisplay information of specific process
psDisplay all active processes
topManage and display all processes in realtime
pstreeDisplay processes in the tree-like diagram
lsofList all files opened by running processes
kill pidKill a specific process using process ID
pidof processnameGet the PID of any process
killall processnameKill all processes by name
bgDisplay stopped or background jobs

Disk Management Commands

In this section, we will show you disk management commands, including add and delete partitions, mount partition, check disk space, format partition, etc.

fdisk /dev/sdaCreate a new partition on /dev/sda device
fdisk -lList all disk partitions
mkfs.ext4 /dev/sda1Format the partition named /dev/sda1
fsck.ext4 /dev/sda1Check and repair a file system for any error
du -hsDisplay the size of your current directory
badblocks -s /dev/sdaTest for unreadable blocks on disk /dev/sda
lsblkDisplay information about block devices
lsusb -tvDisplay all USB devices
mount /dev/sda1 /mntMount any partition to any directory
df -hDisplay free space of mounted file system
df -iDisplay free inodes on the file system
hdparm -tT /dev/sdaPerform a read speed test on disk /dev/sda

Compress and Uncompress Commands

Tar, Zip, and Unzip are the most popular Linux command line utilities used to zip and unzip files and directories.

tar -cvf filename.tar filenameCompress a file in the Tar archive
tar -xvf filename.tarUncompressed a Tar file
tar -tvf filename.tarList the content of the Tar file
zip file1.txt file2.txt file3.txtCompress multiple files to a zip
zip -u file4.txtAdd a file to a zip file
zip -d file4.txtDelete a file from a zip file
unzip -l filename.zipDisplay the content of zip archive file
tar -xvf filename.tar file1.txtUntar a single file from Tar file
unzip -d /dirnameUnzip a file to a specific directory
tar -rvf filename.tar file2.txtAdd a file to the Tar file
zip filenameCompress a single file to a zip
unzip filename.zipUnzip a file

Package Management Command

In this section we will show a list of all commands to install, remove and manage packages in Linux.

apt-get remove packagenameRemove a package on Debian based distributions
apt-get install packagenameInstall the package on Debian based distributions
dpkg -l | grep -i installedGet a list of all packages on Debian based distributions
dpkg -i packagename.debInstall .deb package
apt-get updateUpdate the repository on Debian based distributions
apt-get upgrade packagenameUpgrade a specific package on Delian based distributions
yum updateUpdate all system packages to the latest version on RPM-based distributions
yum list --installedList all installed packages on RPM-based distributions
yum list --availableList all available packages on RPM-based distributions
apt-get autoremoveRemove all unwanted packages on Delian based distributions
yum install packagenameInstall the package on RPM-based distributions
yum remove packagenameRemove a package on RPM-based distributions

PDF Linux Commands CheatSheet

If you’d rather have all the commands on a single page reference sheet, we’ve created a useful Linux command line cheat sheet. You can save the Linux command list in PDF format by clicking the Download Linux Cheat Sheet button below.

Linux Commands CheatSheet Download

Final Thoughts

Feel free to refer to this cheat sheet whenever you need a quick update. The goal here is to save you as much time as possible when trying to remember a certain command. The examples above are the most commonly used Linux commands. Hope this helps you in your daily system administration tasks.

Leave a Reply