If you are a new Linux user, this ultimate Linux commands cheat sheet has everything you need to master the command line. It covers all the most commonly used commands, from file basics (listing, copying, viewing, searching, and setting permissions) to creating and deleting folders, file compression, networking, processes, systems, and file transfer operations.
Why Need The Linux Commands Cheat Sheet?
Whether you’re a Linux expert or just starting, save this cheat sheet for future reference. We packed it with practical commands to help you tackle any task, big or small.
Our Linux Commands Cheat Sheet is a great resource for users of all levels, providing quick and easy access to a range of commands. It can help you learn them, making you a more efficient Linux user.
List of Linux Commands for New Users
Let’s now dive into finding out the most commonly used Linux commands. To help you, we have divided them into different groups. To explain, we have added short examples so that you can easily grasp the usage.
File Operations Commands
Below is the Linux commands cheat list covering the day-to-day file operations. It lists down almost every command you would most likely need to run.
Linux Command | Description |
---|---|
ls | List files and directories with detailed information. |
ls -l | Display in long format with file permissions, owner, size, and modification date. |
ls -a | Show hidden files as well. |
ls -lh | Display human-readable sizes. |
ls *.txt | List all text files in the current directory. |
ls -R /path/to/directory | Recursively list all files and directories in the specified path. |
mkdir | Create a new directory to organize files. |
mkdir -m 777 shared_folder | Create a directory with specific permissions (e.g., 777 for read, write, and execute). |
mkdir -v project1 project2 | Create multiple directories and show the progress for each. |
mkdir -p /path/to/nested/directory | Create nested directories with parents if they don’t exist. |
File Manipulation Commands
Here is a list of file manipulation commands to help you in your routine tasks. Also, learn to manage your files more efficiently than ever.
Linux Command | Description |
---|---|
cp | Copy files or directories to a specified location. |
cp -i file.txt /backup/ | Prompt before overwriting an existing file in the ‘/backup/’ directory. |
cp -u /source/* /destination/ | Copy only newer files from ‘source’ to ‘destination’. |
mv | Move or rename files and directories. |
mv -i old.txt new.txt | Prompt before overwriting an existing file while renaming. |
mv *.txt /backup/ | Move all text files to the ‘/backup/’ directory. |
File View Commands
Debugging and log analysis are some of the common operations, we have to do regularly. The below Linux commands cheat list will make your life easier.
Linux Command | Description |
---|---|
cat | Display the content of a file. |
cat -n file.txt | Display line numbers with the content. |
cat file1.txt file2.txt >merged.txt | Concatenate and merge multiple files into ‘merged.txt’. |
head | View the beginning lines of a file. |
head -n 10 file.txt | Display the first 10 lines of ‘file.txt’. |
head -c 1M file.txt | View the first 1 MB of ‘file.txt’. |
tail | View the last lines of a file. |
tail -n 20 file.txt | Display the last 20 lines of ‘file.txt’. |
tail -f /var/log/syslog | Continuously display new log entries in 'syslog' . |
File Permission Commands
The below Linux commands will help you set up file permissions and groups.
Linux Command | Description |
---|---|
chmod | Change file permissions for users and groups. |
chmod g+s shared_folder | Set the group ID on execution (newly created files inherit the group of the parent directory). |
chmod -R o-rwx /confidential_data | Recursively remove read, write, and execute permissions for others in ‘confidential_data’. |
chown | Change file ownership. |
sudo chown -R root:admin /protected_folder | Change ownership of ‘protected_folder’ to ‘root’ user and ‘admin’ group recursively. |
File Search Commands
The below Linux commands cheat list will make your search faster and increase productivity.
Linux Command | Description |
---|---|
grep | Search for a pattern in files. |
grep -n "error" logfile.txt | Display line numbers with matching results. |
grep -r "function()" src/ --include=*.js | Search for the occurrence of “function()” in JavaScript files only. |
find | Find files and directories based on various criteria. |
find / -type f -iname "*.jpg" -size +1M | Find JPEG files larger than 1 MB case-insensitively from the root directory. |
Compression Commands
Working with large data and files, here is a list of Linux commands to organize your data quickly.
Linux Command | Description |
---|---|
tar | Create or extract tar archives. |
tar -czvf archive.tar.gz folder/ | Create a compressed tar archive of ‘folder/’. |
tar -xzvf archive.tar.gz --wildcards '*.txt' | Extract only ‘.txt’ files from ‘archive.tar.gz’. |
zip | Compress files into a zip archive. |
zip -r archive.zip folder/ -x "*.txt" | Compress ‘folder/’ excluding ‘.txt’ files. |
Networking Commands
Are you experiencing network failures but unable to troubleshoot the issue? Check the below Linux commands cheat list to trace the network problem.
Linux Command | Description |
---|---|
ping | Check network connectivity. |
ping -c 4 google.com | Send 4 packets while pinging. |
ping -i 2 google.com | Set a time-interval of 2 seconds between packets. |
ifconfig | Display network interface information. |
ifconfig eth0 up | Enable the ‘eth0’ network interface. |
ifconfig eth0 down | Disable the ‘eth0’ network interface. |
Process Management
Do you want to know what processes are running on your system? Or Did any process get hanged? The below commands will help you manage the running processes.
Linux Command | Description |
---|---|
ps | Show running processes. |
ps -ef | grep sshd | Filter and display processes with "sshd" string in the output. |
ps -eo pid,ppid,cmd,%mem,%cpu | Customize the output to display process ID, parent process ID, command, memory, and CPU usage. |
kill | Terminate a process. |
kill -9 1234 | Forcefully terminate the process with PID 1234. |
killall -r 'myapp.*' | Kill all processes whose names match the regular expression 'myapp.*' . |
System Info Commands
Do you want to check the OS info like kernel version, and its release versions, or want to know the available space on the disk? Here are the commands you need to know.
Linux Command | Description |
---|---|
uname | Display system information. |
uname -m | Show the machine hardware name. |
uname -o | Display the operating system name. |
df | Show disk space usage. |
df -Th | Display disk space usage with human-readable sizes and file system types. |
df -i /dev/sda1 | Show inode information for the ‘/dev/sda1’ partition. |
Package Management Commands
Sometimes you need something more than a usual command. Here are the Linux Apt commands you should be using then.
Linux Command | Description |
---|---|
apt | Package tool for Debian-based systems. |
apt-get install package-name | Install a package. |
apt update | Update package lists. |
apt search keyword | Search for packages related to a specific keyword. |
apt-cache show package-name | Show detailed information about a package. |
yum | Package manager for RPM-based systems. |
yum update package-name | Update a specific package. |
yum list installed | grep package-name | Check if a package is installed. |
File Deletion Commands
Want to get rid of trash / unwanted files or folders? Check out the following Linux commands.
Linux Command | Description |
---|---|
rm | Remove files or directories. |
rm -f large_file.bin | Forcefully remove ‘large_file.bin’ without prompting. |
rm -i *.txt | Interactively remove all ‘.txt’ files with confirmation. |
rmdir | Delete an empty directory. |
rmdir emptydir | Delete 'emptydir' if it’s empty. |
File Transfer Commands
Check these Linux commands to send data from one machine to another, even if the data is too large to handle. The below commands will help you.
Linux Command | Description |
---|---|
scp | Securely copy files between hosts. |
scp file.txt user@remotehost:/path/to/destination | Copy ‘file.txt’ to ‘remotehost’. |
scp -r remotehost:/path/to/source/destination/ | Copy files and directories from the 'remotehost' to the current directory . |
rsync | Synchronize files and directories. |
rsync -av source/ destination/ | Synchronize ‘source/’ to ‘destination/’. |
rsync -e ssh file.txt user@remotehost:/path/to/destination/ | Synchronize using SSH and copy ‘file.txt’ to ‘remote host’. |
File Permissions (Extended)
Finally, this is the end of this tutorial. Here are some of the advanced examples of the chmod
command.
Linux Command | Description |
---|---|
chmod | Change file permissions with symbolic notation. |
chmod g+s shared_folder | Set the group ID on execution (newly created files inherit the group of the parent directory). |
chmod -R o-rwx /confidential_data | Recursively remove read, write, and execute permissions for others in ‘confidential_data’. |
chmod | Change file permissions using octal values. |
chmod 644 file.txt | Set the read and write permissions for the owner and read-only for the group and others. |
Related Guide – Basic Linux Commands for Beginners With Examples
Before You Leave
In conclusion, you must have realized that the above Linux commands cheat sheet is your key to mastering the command-line interface. You can refer to it to solve your day-to-day problems and harness the full power of Linux commands.
So what are you waiting for? Save this Linux commands cheat sheet today and take its help. Lastly, our site needs your support to remain free. Share this post on social media (Linkedin/Twitter) if you gained some knowledge from this tutorial.
Enjoy learning,
TechBeamers.