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.
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.
Command | Description |
---|---|
date | Display the current system date and time |
hostnamectl | Get system information including, operating system, kernel, and release version |
hostname | Display the hostname of the system |
free -m | Screen free and used memory in the system |
top | Display all running processes |
ls | List all files and directories in the current working directory |
ifconfig | Display the IP and Mac Address of the system |
w | Display currently logged in users in the system |
ls -al | List all files and directories including, hidden files and other information like permissions, size, and owner |
cd | Change the directory to the home directory |
cd .. | Change the directory to one level up |
reboot | Restart the system |
cat filename | Display the content of the file |
mv oldfile newfile | Rename a file |
rm filename | Delete a file |
mkdir dirname | Create a directory |
rm -rf dirname | Remove a directory |
history | Print a history list of all commands |
cat file1 file2 > file3 | Combine two files named file1 and file2 and store the output in a new file file3 |
tail filename | Display the last 10 lines of a file |
head filename | Display the first 10 lines of a file |
clear | Clear the terminal |
shutdown -h now | Shut down the system |
File Permission Commands
Command | Description |
---|---|
chmod 777 filename | Assign full(read, write, and execute) permission to everyone |
ls -l filename | Check the current permission of any file |
chmod -R 777 dirname | Assign full permission to the directory and all sub-directories |
chmod 766 filename | Assign full permission to the owner, and read and write permission to group and others |
chown -R user:group dirname | Change the owner and group ownership of the directory and all sub-directories |
chmod -x filename | Remove the execution permission of any file |
chown username filename | Change the ownership of a file |
chown user:group filename | Change the owner and group ownership of a file |
Networking Commands
Command | Description |
---|---|
ip addr add IP-Address dev eth1 | Add a temporary IP address to interface eth1 |
ip addr show Or ifconfig | List all IP addresses and network interfaces |
netstat -pnltu | Display all listening port |
whois domainname | Display more information about any domain |
host domainname | Perform an IP lookup for a domain |
ping host-ip | Check connectivity between two hosts |
dig -x IP-Address | Perform a reverse lookup of an IP address |
dig domainname | Display DNS information of any domain |
dig -x domainame | Perform 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.
Command | Description |
---|---|
w | Display all login users |
useradd username | Add a new user account |
userdel -r username | Delete a user account |
id | Display UID and GID of the current user |
usermod [option] username | Change the user account information including, group, home directory, shell, expiration date |
usermod -aG groupname username | Add a user to a specific group |
groupadd groupname | Create a new group |
groupdel groupname | Remove a group |
last | Display 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.
Command | Description |
---|---|
ps -ef | grep processname | Display information of specific process |
ps | Display all active processes |
top | Manage and display all processes in realtime |
pstree | Display processes in the tree-like diagram |
lsof | List all files opened by running processes |
kill pid | Kill a specific process using process ID |
pidof processname | Get the PID of any process |
killall processname | Kill all processes by name |
bg | Display 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.
Command | Description |
---|---|
fdisk /dev/sda | Create a new partition on /dev/sda device |
fdisk -l | List all disk partitions |
mkfs.ext4 /dev/sda1 | Format the partition named /dev/sda1 |
fsck.ext4 /dev/sda1 | Check and repair a file system for any error |
du -hs | Display the size of your current directory |
badblocks -s /dev/sda | Test for unreadable blocks on disk /dev/sda |
lsblk | Display information about block devices |
lsusb -tv | Display all USB devices |
mount /dev/sda1 /mnt | Mount any partition to any directory |
df -h | Display free space of mounted file system |
df -i | Display free inodes on the file system |
hdparm -tT /dev/sda | Perform 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.
Command | Description |
---|---|
tar -cvf filename.tar filename | Compress a file in the Tar archive |
tar -xvf filename.tar | Uncompressed a Tar file |
tar -tvf filename.tar | List the content of the Tar file |
zip filename.zip file1.txt file2.txt file3.txt | Compress multiple files to a zip |
zip -u filename.zip file4.txt | Add a file to a zip file |
zip -d filename.zip file4.txt | Delete a file from a zip file |
unzip -l filename.zip | Display the content of zip archive file |
tar -xvf filename.tar file1.txt | Untar a single file from Tar file |
unzip filename.zip -d /dirname | Unzip a file to a specific directory |
tar -rvf filename.tar file2.txt | Add a file to the Tar file |
zip filename.zip filename | Compress a single file to a zip |
unzip filename.zip | Unzip a file |
Package Management Command
In this section we will show a list of all commands to install, remove and manage packages in Linux.
Command | Description |
---|---|
apt-get remove packagename | Remove a package on Debian based distributions |
apt-get install packagename | Install the package on Debian based distributions |
dpkg -l | grep -i installed | Get a list of all packages on Debian based distributions |
dpkg -i packagename.deb | Install .deb package |
apt-get update | Update the repository on Debian based distributions |
apt-get upgrade packagename | Upgrade a specific package on Delian based distributions |
yum update | Update all system packages to the latest version on RPM-based distributions |
yum list --installed | List all installed packages on RPM-based distributions |
yum list --available | List all available packages on RPM-based distributions |
apt-get autoremove | Remove all unwanted packages on Delian based distributions |
yum install packagename | Install the package on RPM-based distributions |
yum remove packagename | Remove 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.