Linux Commands Cheat Sheet
Last Updated : 01/31/2023
There are hundreds – possibly thousands – commands available in Linux. Remembering every command is not possible and it can be quite daunting for a novice user. The good news is that you don't need to remember each command. Only a very small subset of those commands are used on a day-to-day basis.
This cheat sheet offers a set of commands that you can use for quick reference. I have prepared this Linux Commands Cheat Sheet as quick reference for both experienced and basic users.
Basic Linux Commands
In this section, we will show you some basic Linux commands with examples.
|Get system information including, operating system, kernel, and release version|
|Display the current system date and time|
|Display the hostname of the system|
|Display the IP and Mac Address of the system|
|Display currently logged in users in the system|
|Display free and used memory in the system|
|Display all running processes|
|List all files and directories in the current working directory|
|List all files and directories including, hidden files and other information like permissions, size, and owner|
|Change the directory to the home directory|
|Change the directory to one level up|
|Display the content of the file|
|Combine two files named file1 and file2 and store the output in a new file file3|
|Display the last 10 lines of a file|
|Display the first 10 lines of a file|
|Rename a file|
|Delete a file|
|Create a directory|
|Remove a directory|
|Print a history list of all commands|
|Clear the terminal|
|Shut down the system|
|Restart the system|
|List all IP addresses and network interfaces|
|Add a temporary IP address to interface eth1|
|Display all listening port|
|Display more information about any domain|
|Display DNS information of any domain|
|Perform an IP lookup for a domain|
|Perform a reverse lookup of an IP address|
|Perform a reverse lookup on domain|
|Check connectivity between two hosts|
File Permission Commands
|Check the current permission of any file|
|Assign full(read, write, and execute) permission to everyone|
|Assign full permission to the directory and all sub-directories|
|Assign full permission to the owner, and read and write permission to group and others|
|Remove the execution permission of any file|
|Change the ownership of a file|
|Change the owner and group ownership of a file|
|Change the owner and group ownership of the directory and all sub-directories|
User and Group Management Commands
Linux is a multi-user operating system. So multiple users can log in to 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 like files and directories. In that case, user and group management allows you to complete your objectives.
|Display all login users|
|Add a new user account|
|Delete a user account|
|Change the user account information including, group, home directory, shell, expiration date|
|Add a user to a specific group|
|Create a new group|
|Remove a group|
|Display information of the last login user|
|Display UID and GID of the current user|
Process Management Commands
When you run any application in Linux. The application will get a process ID or PID. Process Management helps you to monitor and manage your application.
|Display all active processes|
|Display information of specific process|
|Manage and display all processes in realtime|
|Display processes in the tree-like diagram|
|List all files opened by running processes|
|Kill a specific process using process ID|
|Kill all processes by name|
|Display stopped or background jobs|
|Get the PID of any process|
Disk Management Commands
In this section, we will show you disk management commands including, add and remove partitions, mount a partition, check disk space, format partition, etc.
|List all disk partitions|
|Create a new partition on /dev/sda device|
|Format the partition named /dev/sda1|
|Check and repair a filesystem for any error|
|Mount any partition to any directory|
|Display free space of mounted file system|
|Display free inodes on the filesystem|
|Display the size of your current directory|
|Display information about block devices|
|Display all USB devices|
|Perform a read speed test on disk /dev/sda|
|Test for unreadable blocks on disk /dev/sda|
Package Management Command
In this section, we will show a list of all commands to install, remove and manage packages in Linux.
|Install the package on Debian based distributions|
|Remove a package on Debian based distributions|
|Get a list of all packages on Debian based distributions|
|Install .deb package|
|Update the repository on Debian based distributions|
|Upgrade a specific package on Debian based distributions|
|Remove all unwanted packages on Debian based distributions|
|Install the package on RPM-based distributions|
|Remove a package on RPM-based distributions|
|Update all system packages to the latest version on RPM-based distributions|
|List all installed packages on RPM-based distributions|
|List all available packages on RPM-based distributions|
Compress and Uncompress Commands
Tar, Zip, and Unzip are the most popular command-line utility in Linux used to compress and uncompress files and directories.
|Compress a file in the Tar archive|
|Uncompress a Tar file|
|List the content of the Tar file|
|Untar a single file from Tar file|
|Add a file to the Tar file|
|Compress a single file to a zip|
|Compress multiple files to a zip|
|Add a file to a zip file|
|Delete a file from a zip file|
|Display the content of zip archive file|
|Unzip a file|
|Unzip a file to a specific directory|
The above examples are the most commonly used Linux commands. I hope this will help you to perform your day-to-day system administration task.
Linux Commands Cheat Sheet FAQs
What are some basic Linux commands?
Some basic Linux commands include "ls" to list the files in a directory, "cd" to change directories, "mkdir" to create a new directory, "touch" to create a new file, "rm" to delete a file, "cp" to copy a file, "mv" to move a file, "pwd" to display the current directory, "echo" to display text on the screen, and "man" to display the manual for a command.
How do I navigate the file system in Linux?
To navigate the file system in Linux, use the "cd" command to change directories, "ls" command to list the contents of a directory, and "pwd" command to display the current directory. You can also use the ".." notation to move up one directory level and "~" to move to the home directory.
How do I create and edit files in Linux?
To create a new file in Linux, use the "touch" command followed by the file name. To edit a file, you can use a text editor such as "vi" or "nano". For example, "vi file.txt" or "nano file.txt"
How do I manage permissions in Linux?
To manage permissions in Linux, use the "chmod" command to change the permissions of a file or directory. Permissions can be represented by numbers or symbols such as "rwx" for read, write, and execute. Additionally, you can use "chown" command to change the owner and group of a file or directory.
How do I find and install software in Linux?
To find and install software in Linux, you can use package managers such as "apt" or "yum" depending on the Linux distribution. For example, "apt-get install [package name]" or "yum install [package name]". You can also use the "which" command to find the location of a installed program.
How do I use wildcards in Linux commands?
Wildcards in Linux commands are represented by the "*" symbol. For example, "ls *" will list all files in the current directory, "ls *.txt" will list all files with the ".txt" extension, and "rm *" will delete all files in the current directory.
How can I get help with a Linux command?
To get help with a Linux command, you can use the "man" command followed by the name of the command. For example, "man ls" will display the manual page for the "ls" command. You can also use "--help" option after the command, for example "ls --help" will show the options available with the command.