Johannes is an DevOps engineer with passion for solving problem and learning new technologies. Johannes has the skill and experience about improving performance and also reducing infrastructure cost to help you achieve your goals.
Looking for Elite Digital Talent?
Hire vetted candidates within 2 weeks and save hiring cost up to 70%
As a Linux user, you can tell that there are countless commands at your disposal – hundreds, if not thousands – which can seem overwhelming to novice users.
However, fear not! You don't need to memorize every single one of them. In fact, only a small subset of these commands are commonly used on a day-to-day basis.
To make things easier for both experienced and basic users here is a cheat sheet that you can use as a quick reference guide. This Linux cheat sheet command will provide you with a set of commands that you can easily access when needed.
The Most Frequent Used Command
Before we delve into the cheat sheet, let's take a look at the most frequently used commands.
Some common Linux commands include "ls" to list directory contents, "cd" to change directories, "mkdir" to create directories, "touch" to create files, "rm" to remove files, "cp" to copy files, "mv" to move files, "pwd" to display the current directory, "echo" to print text on the screen, and "man" to display the manual for a command.
To navigate the Linux file system, use "cd" to change directories, "ls" to list the directory contents, and "pwd" to display the current directory. The ".." notation can be used to move up one directory level and "~" to move to the home directory.
To create and edit files, use "touch" to create a new file and "vi" or "nano" to edit an existing file.
Permissions in Linux can be managed using the "chmod" command to change permissions and "chown" to change ownership and group.
To find and install the the software in Linux, use package managers such as "apt" or "yum", and to locate the installed programs use "which" command.
Wildcards in Linux commands are represented by the "*" symbol. For example, "ls *" will list all files in the current directory.
To get help with a Linux command, use "man" followed by the command name or "--help" option after the command.
Basic Linux Command
In the following section, we'll cover some basic Linux commands along with examples to help you get started. So, let's dive in!
ls
Lists all files and directories in the present working directory
ls -R
Lists files in sub-directories as well
ls -a
Lists hidden files as well
ls -al
Lists files and directories with detailed information like permissions, size, owner, etc.
cd or cd ~
Navigate to the HOME directory
cd ..
Move one level up
cd
To change to a particular directory
cd /
Move to the root directory
cat > filename
Creates a new file
cat filename
Displays the file content
cat file1 file2 > file3
Joins two files (file1, file2) and stores the output in a new file (file3)
mv file "new file path"
Moves the files to the new location
mv filename new_file_name
Renames the file to a new filename
sudo
Allows regular users to run programs with the security privileges of the superuser or root
rm filename
Deletes a file
man
Gives help information on a command
history
Gives a list of all past commands typed in the current terminal session
clear
Clears the terminal
rmdir
Deletes a directory
mv
Renames a directory
pr -x
Divides the file into x columns
pr -h
Assigns a header to the file
pr -n
Denotes the file with Line Numbers
lp -nc , lpr c
Prints “c” copies of the File
lp-d lp-P
Specifies the name of the printer
apt-get
The command used to install and update packages
mail -s 'subject'-c 'cc-address'-b 'bcc-address''to-address'
Command to send email
mail -s "Subject"to-address Filename
Command to send an email with an attachment
date
Display the current system date and time
hostname
Display the hostname of the system
ifconfig
Display the IP and Mac Address of the system
w
Display currently logged-in users in the system
free -m
Display free and used memory in the system
top
Display all running processes
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
mv oldfile newfile
Rename a file
mkdir dirname
Create a directory
rm -rf dirname
Remove a directory
history
Print a history list of all commands
clear
Clear the terminal
shutdown -h now
Shut down the system
reboot
Restart the system
File Permission Command
In Linux, file permissions are essential to protect system files and user data from unauthorized access. A permission command is a powerful tool that allows you to manage and modify the access rights of files and directories.
This command consists of three groups of permissions, namely owner, group, and other, each with three permission types - read, write, and execute. The permission command allows you to set permissions on a file or directory using either symbolic or octal notation.
With symbolic notation, you can use letters such as r, w, and x to represent read, write, and execute, while octal notation uses numbers to represent permission types. A permission command is a crucial tool for managing user access in Linux, ensuring that sensitive files and directories remain secure and protected.
ls -l filename
Check the current permission of any file
chmod 777 filename
Assign full(read, write, and execute) permission to everyone
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 the group and others
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
chown -R user:group dirname
Change the owner and group ownership of the directory and all sub-directories
ls -l
to show file type and access permission
r
read permission
w
write permission
x
execute permission
-=
no permission
Chown user
For changing the ownership of a file/directory
Chown user:group filename
change the user as well as a group for a file or directory
Process Command
Commands related to processes enable you to perform various tasks, including observing active processes, initiating or terminating processes, and examining process efficiency.
bg
To send a process to the background
fg
To run a stopped process in the foreground
top
Details on all Active Processes
ps
Give the status of processes running for a user
ps PID
Gives the status of a particular process
pidof
Gives the Process ID (PID) of a process
nice
Starts a process with a given priority
renice
Changes the priority of an already running process
df
Gives free hard disk space on your system
free
Gives free RAM on your system
ps -ef | grep processname
Display information on the specific process
pstree
Display processes in the tree-like diagram
lsof
List all files opened by running processes
kill pid
Kill a specific process using a process ID
killall processname
Kill all processes by name
bg
Display stopped or background jobs
pidof processname
Get the PID of any process
Disk Management Commands
This section will demonstrate disk management commands that cover actions such as creating or deleting partitions, mounting partitions, verifying available disk space, formatting partitions, and more.
fdisk -l
List all disk partitions
fdisk /dev/sda
Create a new partition on /dev/sda device
mkfs.ext4 /dev/sda1
Format the partition named /dev/sda1
fsck.ext4 /dev/sda1
Check and repair a filesystem for any error
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 filesystem
du -hs
Display the size of your current directory
lsblk
Display information about block devices
lsusb -tv
Display all USB devices
hdparm -tT /dev/sda
Perform a read speed test on disk /dev/sda
badblocks -s /dev/sda
Test for unreadable blocks on disk /dev/sda
Compress and Uncompress Commands
The command-line utilities Tar, Zip, and Unzip are widely used in Linux to compress and decompress directories and files and are among the most commonly used tools for this purpose.
tar -cvf filename.tar filename
Compress a file in the Tar archive
tar -xvf filename.tar
Uncompress a Tar file
tar -tvf filename.tar
List the content of the Tar file
tar -xvf filename.tar file1.txt
Untar a single file from the Tar file
tar -rvf filename.tar file2.txt
Add a file to the Tar file
zip filename.zip filename
Compress a single file to a zip
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 the zip archive file
unzip filename.zip
Unzip a file
unzip filename.zip -d /dirname
Unzip a file to specific directory
Networking Commands
These commands enable you to manage network interfaces, troubleshoot network issues, and configure network settings. They also allow you to view network information, set IP addresses, configure routing tables, and establish network connections.
SSH username@ip-address or hostname
login into a remote Linux machine using SSH
Ping hostname="" or =""
To ping and Analyze network and host connections
dir
Display files in the current directory of a remote computer
cd "dirname"
change the directory to “dirname” on a remote computer
put file
upload ‘file’ from a local to a remote computer
get file
Download the ‘file’ from the remote to the local computer
quit
Logout
VI Editing Commands
VI editing commands are a set of keyboard shortcuts used to navigate and edit the text within the VI editor in Linux. These commands are essential for users who frequently work with the VI editor, as they allow you to move the cursor, delete, copy, paste, and modify text within a file.
VI editing commands are powerful tools that allow for quick and efficient text editing within the VI editor.
i
Insert at cursor (goes into insert mode)
a
Write after the cursor (goes into insert mode)
A
Write at the end of the line (goes into insert mode)
ESC
Terminate insert mode
u
Undo last change
U
Undo all changes to the entire line
o
Open a new line (goes into insert mode)
dd
Delete line
3dd
Delete 3 lines
D
Delete the contents of the line after the cursor
C
Delete the contents of a line after the cursor and insert new text. Press the ESC key to end insertion.
dw
Delete word
4dw
Delete 4 words
cw
Change word
x
Delete the character at the cursor
r
Replace character
R
Overwrite characters from cursor onward
s
Substitute one character under the cursor and continue to insert
S
Substitute the entire line and begin to insert at the beginning of the line
~
Change case of individual character
Conclusion
We hope these Linux cheat sheet commands provide a helpful resource for both beginners and experienced users to improve their productivity and efficiency when using the Linux operating system.
Whether you are looking to manage files and directories, install software packages, or navigate the file system, the cheat sheet commands have got you covered.
Additionally, if you are in need of top-tier remote DevOps engineers for your organization, consider checking out Talentport. With our streamlined hiring process, you can have access to highly skilled professionals in just two weeks, resulting in a 300% return on investment for your hiring budget.
Don't hesitate to take advantage of this opportunity to elevate your team's capabilities and achieve your business goals. Start hiring now!
Don’t forget to join our news letter to know how’s the industry going
Hiring a software engineer is not easy, especially.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.