Linux Commands Cheat Sheet
Linux Commands Cheat Sheet
What is Linux?
cd cd /path/to/directory
Change changes the current
directory. directory to the
specified path.
rm -f file.txt
forcefully deletes the
file “file.txt” without
confirmation.
cp cp -r directory
destination
copies the directory
“directory” and its
-r: Copy
Copy files and contents to the
directories
directories. specified destination.
recursively.
cp file.txt destination
copies the file “file.txt”
to the specified
destination.
mv mv file.txt
new_name.txt
renames the file
Move/rename “file.txt” to
files and “new_name.txt”.
directories. mv file.txt directory
moves the file “file.txt”
to the specified
directory.
touch Create an
touch file.txt
empty file or
creates an empty file
update file
named “file.txt”.
timestamps.
head -n 5 file.txt
displays the first 5
lines of the file
“file.txt”.
ln ln -s source_file
link_name
-s: Create
Create links creates a symbolic link
symbolic (soft)
between files. named “link_name”
links.
pointing to
“source_file”.
chmod u: User/owner
permissions.
g: Group
permissions.
o: Other
chmod u+rwx file.txt
permissions.
Change file grants read, write, and
+: Add
permissions. execute permissions to
permissions.
the owner of the file.
–: Remove
permissions.
=: Set
permissions
explicitly.
ps ps aux
shows all running
Display running -aux: Show all processes with
processes. processes. detailed
information.
top top
displays a dynamic
Monitor system
view of system
processes in real-
processes and
time.
their resource
usage.
pkill pkill
Terminate process_name
processes based terminates all
on their name. processes with the
specified name.
pgrep pgrep
process_name
List processes
lists all processes
based on their
with the specified
name.
name.
the matching
line.
-C: Display
lines both
before and
after the
matching line.
uname uname -a
Print system -a: All system
displays all system
information. information.
information.
whoami whoami
Display current
shows the current
username.
username.
df df -h
-h: Human-
Show disk space displays disk space
readable
usage. usage in a human-
sizes.
readable format.
du -h: Human-
du -sh directory/
readable
Estimate file and provides the total
sizes.
directory sizes. size of the
-s: Display
specified directory.
total size only.
free free -h
Display memory -h: Human-
displays memory
usage readable
usage in a human-
information. sizes.
readable format.
sudCommand Description Options Examples
uptime uptime
Show system
shows the current
uptime.
system uptime.
lscpu lscpu
Display CPU provides detailed
information. CPU information.
lspci lspci
List PCI devices.
List PCI devices.
lsusb lsusb
List USB lists all connected
devices. USB devices.
6. Networking Commands
In Linux, there are several networking commands available to manage and
troubleshoot network connections. Here are some commonly used
networking commands:
ss ss -tuln
Display network
shows all listening TCP and UDP
socket
connections.
information.
7. IO Redirection Commands
In Linux, IO (Input/Output) redirection commands are used to redirect the
standard input, output, and error streams of commands and processes. Here
are some commonly used IO redirection commands:
Command Description
cmd1 <(cmd2) Output of cmd2 is used as the input file for cmd1.
cmd > /dev/null Discards the stdout of cmd by sending it to the null device.
Command Description
export
Sets the value of an environment variable.
VARIABLE_NAME=value
Command Description
sudo adduser Create a new user account on the system with the
username specified username.
Cut/delete
from the Search
Move to the cursor command
Ctrl + A beginning of Ctrl + U position to Ctrl + R history
the line. the (reverse
beginning of search).
the line.
Cut/delete
from the
Move to the Escape from
cursor
Ctrl + E end of the Ctrl + K Ctrl + G history
position to
line. search mode.
the end of
the line.
Cut/delete Go to the
Move back
Ctrl + the word previous
Ctrl + B one Ctrl + P
W before the command in
character.
cursor. history.
Navigation Description Editing Description History Description
Go to the
Move
Paste the next
Ctrl + F forward one Ctrl + Y Ctrl + N
last cut text. command in
character.
history.
Terminate
Move back Clear the
Alt + B Ctrl + L Ctrl + C the current
one word screen.
command.
Move
Alt + F forward one
word.
Cut/del
from t
Save the Scroll up one curso
Ctrl + O Ctrl + Y Ctrl + K
file. page. position
the end
the lin
Exit Nano
Uncut/re
(prompt to Scroll down
Ctrl + X Ctrl + V Ctrl + U the last
save if one page.
text
modified).
Go to the
Justify the Cut/del
beginning of
Ctrl + J current Alt + , Ctrl + K the mar
the current
paragraph. block of
line.
Go to the Copy t
Alt + . end of the Alt + 6 marked b
current line. of tex
Command Description
Change the current word. Deletes from the cursor position to the
cw
end of the current word and switches to insert mode.
o Insert a new line below the current line and switch to insert mode.
dw Delete from the cursor position to the beginning of the next word.
4dw Delete the next four words from the cursor position.
3dd Delete the current line and the two lines below it.
Restore the current line to its original state before any changes
U
were made.
Delete from the cursor position to the end of the line and switch to
C
insert mode.
Enter insert
mode at the Enter visual
i current :w Save the file. v mode to
cursor select text.
position.
Normal Description Command Description Visual Description
Mode Mode Mode
Delete the
Copy the
character
x :q Quit Vim. y selected
under the
text.
cursor.
Quit Vim
Delete the
Delete the without
dd :q! d selected
current line. saving
text.
changes.
:wq
Paste the
Copy the Save and
yy or p copied or
current line. quit Vim.
:x deleted text.
:set nu
Undo the or Display line
u
last change. numbers.
:set number
Conclusion
In conclusion, Linux is a widely used operating system for development, and
as a developer, you should have knowledge of Linux and its basic
commands. In this Cheat Sheet, we covered all commands like creating
directories, file compression and archiving, process management, system
information, networking and more. In addition to that, this Linux Cheat Sheet