Linux Cheat Sheet
Linux Cheat Sheet
Whether you’re a beginner getting your hands dirty or a seasoned sysadmin managing hundreds of servers, mastering the Linux command line is a must.
This article will guide you through:
- Application and Package Management
- Console and Output Management
- Environment Variables
- File and Directory Operations
- Networking Essentials
- Process and System Control
- Common Compound Operations
- Useful Lookup and Diagnostic Tools
- Realistic Usage Scenarios
- Key Best Practices and Takeaways
Let’s dive into each section with practical examples and clear explanations.

Application and Package Management
which
Shows the full path of an installed command.
which clear
dnf / yum
Install, list, remove, and manage packages on RHEL-based systems.
sudo dnf install net-tools
sudo yum remove net-tools
sudo yum list net-tools
Console and Output Management
cat
Displays the contents of a file.
cat /etc/system-release
clear
Clears the terminal screen.
clear
echo
Prints text to the screen or writes to a file.
echo "Hello"
echo "data" >> file.txt
top
Shows active processes and system performance.
top
more
Views large files one page at a time.
cat /var/log/audit/audit.log | more
man
Displays manual pages for a command.
man grep
Environment Variables
env
Lists all current environment variables.
env
export
Sets and exports an environment variable.
export MY_VAR="1907"
printenv
Prints the value of a specific environment variable.
printenv USER
source
Executes a script in the current shell.
source ~/.bashrc
File and Directory Operations
cd
Changes the current directory.
cd /home/
cp
Copies files or directories.
cp file1.txt file2.txt
mv
Moves or renames files or directories.
mv oldname.txt newname.txt
rm
Deletes files or directories.
rm file.txt
rm -r directory/
mkdir
Creates a new directory.
mkdir new_folder
ls
Lists files and directories.
ls
ls -lart
pwd
Prints the current working directory.
pwd
find
Searches for files and directories.
find / -name filename.txt
grep
Searches for patterns within files.
grep "PATH" ~/.bashrc
tar
Compresses or extracts files from archives.
tar -czvf archive.tar.gz folder/
tar -xzvf archive.tar.gz
Networking Essentials
curl
Transfers data from or to a server.
curl https://example.com

wget
Downloads files from the web.
wget http://example.com/file.zip
ip
Displays or manipulates IP configuration.
ip a
ifconfig
Legacy command to display network interfaces.
ifconfig
netstat
Displays network connections, routing tables, etc.
netstat -tulnpa
ss
Displays detailed socket statistics.
ss -tuln
nslookup
Performs DNS lookups.
nslookup google.com
traceroute
Traces the route packets take to a host.
traceroute google.com
ssh
Connects securely to remote machines.
ssh user@***.ipadres.****
Process and System Control
ps
Displays information about active processes.
ps aux
kill
Terminates processes by PID.
kill 1234
poweroff
Shuts down the machine.
sudo poweroff
reboot
Restarts the machine.
sudo reboot
whoami
Prints the current user’s username.
whoami
hostname
Displays or sets the system hostname.
hostname
Common Compound Operations
&&
Runs multiple commands sequentially only if the previous succeeds.
mkdir test && cd test
Realistic Usage Scenarios
Check system version:
cat /etc/system-release
Download a file from the web:
wget https://www.google.com
Compress a folder:
tar -czvf backup.tar.gz myfolder/
Search for IP configuration:
ip a | grep inet
Kill a stuck process:
ps aux | grep myapp
kill <PID>
Key Best Practices and Takeaways
- Use
man <command>to learn more about any tool. - Prefer
dnfoveryumon newer RHEL-based systems. - Use
&&to chain dependent commands safely. - Use
sourceto reload environment settings without logging out. - Always double-check before using
rm -rto avoid irreversible deletion.
Conclusion
This cheat sheet is your foundation for becoming efficient in the Linux terminal. Each command here is a powerful tool in your daily toolkit — whether you’re editing files, managing packages, debugging networks, or controlling processes. Save this guide, refer back often, and continue exploring what the CLI can do for you.
← PostgreSQL Blog