Linux Commands Cheat Sheet - Beginner To Advanced
Linux Commands Cheat Sheet - Beginner To Advanced
By the end of this cheat sheet, you will have a basic understanding of Linux/Unix
Commands and how it makes development easy for developers.
What is Linux?
Linux is an open-source UNIX-like operating system (OS). An operating system is a
software that directly manages a system’s hardware and resources, like CPU, memory,
and storage. OS acts as a GUI through which user can communicate with the computer.
The OS sits between applications and hardware and makes the connections between all
of your software and the physical resources that do the work.
ls ls -l
displays files and directories
-l: Long format
with detailed information.
listing.
ls -a
List files and -a: Include hidden
shows all files and
directories. files hidden ones
directories, including
-h: Human-
ls -lh
readable file sizes.
displays file sizes in a
human-readable format.
cd cd /path/to/directory
Change directory. changes the current directory
to the specified path.
pwd pwd
Print current
displays the current working
working directory.
directory.
rm rm file.txt
deletes the file named
“file.txt”.
-r: Remove
rm -r my_directory
directories
deletes the directory
Remove files and recursively.
“my_directory” and its
directories. -f: Force removal
contents.
without
rm -f file.txt
confirmation.
forcefully deletes the file
“file.txt” without
confirmation.
specified destination.
mv mv file.txt new_name.txt
renames the file “file.txt” to
Move/rename files “new_name.txt”.
and directories. mv file.txt directory
moves the file “file.txt” to the
specified directory.
ln ln -s source_file link_name
-s: Create
Create links creates a symbolic link
symbolic (soft)
between files. named “link_name” pointing
links.
to “source_file”.
find Search for files and -name: Search by find /path/to/search -name
directories. filename. “*.txt”
-type: Search by searches for all files with the
file type.
HTML Cheat Sheet CSS Cheat
Command Sheet JS Cheat Sheet
Description Bootstrap
Options Cheat Sheet jQuery Cheat Sheet Angular Cheat Sheet
Examples SD
chmod u: User/owner
permissions.
g: Group
permissions.
o: Other
chmod u+rwx file.txt
permissions.
Change file grants read, write, and execute
+: Add
permissions. permissions to the owner of the
permissions.
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-time.
processes and their
resource usage.
grep used to search for -i: Ignore case grep -i “hello” file.txt
specific patterns or distinctions while grep -v “error” file.txt
regular expressions in searching. grep -r “pattern”
text files or streams and -v: Invert the directory/
display matching lines. match, displaying grep -l “keyword”
non-matching file.txt
lines. grep -n “pattern”
-r or -R: file.txt
Recursively In these examples we
search directories are extracting our
for matching desirec output from
patterns. filename (file.txt)
Commands Description Options Examples
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
Show disk space -h: Human- displays disk space usage
usage. readable sizes. in a human-readable
format.
du -h: Human-
du -sh directory/
Estimate file and readable sizes.
provides the total size of
directory sizes. -s: Display total
the specified directory.
size only.
free free -h
Display memory -h: Human-
displays memory usage in
usage information. readable sizes.
a human-readable format.
uptime uptime
Show system
shows the current system
uptime.
uptime.
lscpu lscpu
Display CPU provides detailed CPU
information. information.
lspci lspci
List PCI devices.
List PCI devices.
lsusb lsusb
lists all connected USB
List USB devices.
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 socket
shows all listening TCP and UDP 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 usermod -a -G
Add an existing user to the specified group. The user is added
GROUPNAME
to the group without removing them from their current groups.
USERNAME
Cut/delete from
Escape from
Move to the the cursor position
Ctrl + E Ctrl + K Ctrl + G history search
end of the line. to the end of the
mode.
line.
Go to the
Cut/delete the
Move back one Ctrl + previous
Ctrl + B word before the Ctrl + P
character. W command in
cursor.
history.
Go to the next
Move forward Paste the last cut
Ctrl + F Ctrl + Y Ctrl + N command in
one character. text.
history.
Terminate the
Move back one
Alt + B Ctrl + L Clear the screen. Ctrl + C current
word
command.
Navigation Description Editing Description History Description
Move forward
Alt + F
one word.
Cut/delete
from the
Save the Scroll up one cursor
Ctrl + O Ctrl + Y Ctrl + K Ctrl +
file. page. position to
the end of
the line.
Exit Nano
Uncut/restore
(prompt to Scroll down
Ctrl + X Ctrl + V Ctrl + U the last cut Alt +
save if one page.
text.
modified).
Go to the
Justify the Cut/delete
beginning of
Ctrl + J current Alt + , Ctrl + K the marked
the current
paragraph. block of text.
line.
Change the current word. Deletes from the cursor position to the end of the
cw
current word and switches to insert mode.
Enter replace mode. Overwrites characters starting from the cursor position until
R
you press the Escape key.
o Insert a new line below the current line and switch to insert mode.
s Substitute the character under the cursor 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.
Replace the character under the cursor with a new character entered from the
r
keyboard.
3dd Delete the current line and the two lines below it.
ESC Exit from insert or command-line mode and return to command mode.
U Restore the current line to its original state before any changes were made.
C Delete from the cursor position to the end of the line and switch to insert mode.
Enter insert
Enter visual
mode at the
i :w Save the file. v mode to select
current cursor
text.
position.
Delete the
Copy the
x character under :q Quit Vim. y
selected text.
the cursor.
:wq
Paste the
Copy the current Save and quit
yy or p copied or
line. Vim.
deleted text.
:set nu
Undo the last or Display line
u
change. numbers.
:set number
PS. Don’t miss our other Python cheat sheet for data science that covers Scikit-
Learn, Bokeh, Pandas and Python basics.
When your memory fails or you prefer not to rely on “linux –help?” in the Terminal,
this linux cheat sheet comes to the rescue. It is hard to memorize all the important
linux Commandsby heart, so print this out or save it to your desktop to resort to
when you get stuck.
Kernel. The base component of the OS. Without it, the OS doesn’t work. …
System user space. The administrative layer for system-level tasks like
configuration and software install. …
Applications. A type of software that lets you perform a task.
You might have heard of chmod 777. This command will give read, write and
execute permission to the owner, group and public.
Using the w Command, w command in Linux shows logged-in users and their
activities.
Here's a complete roadmap for you to become a developer: Learn DSA -> Master
Frontend/Backend/Full Stack -> Build Projects -> Keep Applying to Jobs
And why go anywhere else when our DSA to Development: Coding Guide helps you do
this in a single program! Apply now to our DSA to Development Program and our
counsellors will connect with you for further guidance & support.
15 Suggest improvement
Previous Next
NumPy Cheat Sheet: Beginner to Advanced Pandas Cheat Sheet for Data Science in Python
(PDF)
Similar Reads
jQuery Cheat Sheet – A Basic Guide to jQuery Tkinter Cheat Sheet
J jayes5h62
Company Explore
About Us Hack-A-Thons
Legal GfG Weekly Contest
Careers DSA in JAVA/C++
In Media Master System Design
Contact Us Master CP
Advertise with us GeeksforGeeks Videos
GFG Corporate Solution Geeks Community
Placement Training Program
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL Top 100 DSA Interview Problems
R Language DSA Roadmap by Sandeep Jain
Android Tutorial All Cheat Sheets
Tutorials Archive