Prakhar Singh

The Ultimate Linux Commands Cheat Sheet

Cover Image for The Ultimate Linux Commands Cheat Sheet
Prakhar Singh
Prakhar Singh

Getting Started with Linux: A Beginner's Guide to Basic Commands


One of the most empowering aspects of using Linux is mastering the command line. While the graphical user interface (GUI) provides a visual way to interact with the system, the command line offers unparalleled control and efficiency.

Note: Linux is nothing more than a group of files.

1. Displaying Text


bash
echo Hello, World!

Output:

text
Hello, World!

2. Navigating the File System


pwd – Print Working Directory

bash
pwd

Example output:

text
/ home / username

ls – List Directory Contents

bash
ls

ls -a – List All Files (Including Hidden)

bash
ls -a

ls / – List Root Directory

bash
ls /

cd – Change Directory

bash
cd Documents
bash
cd /
bash
cd ..
bash
cd -
bash
cd --

3. File and Directory Operations

Create Directory

bash
mkdir new_directory

Create File

bash
touch newfile.txt

Copy Files

bash
cp source.txt destination.txt

Copy Directories

bash
cp -r source_directory destination_directory

Move / Rename

bash
mv oldname.txt newname.txt

Remove Files

bash
rm file.txt

Remove Directories

bash
rm -r directory_name

4. Viewing and Editing Files

View File Content

bash
cat file.txt

Page-by-Page Viewing

bash
less file.txt
more file.txt

Edit with vi

bash
vi file.txt

5. System Commands

Clear Terminal

bash
clear

Search Files

bash
find / -name filename

Command History

bash
history

Switch to Superuser

bash
sudo su -

Update Package Index (Debian-based)

bash
sudo apt update

Advanced Linux Commands :


6. Text Processing

grep

bash
grep "pattern" file.txt

sed

bash
sed 's/old/new/g' file.txt

awk

bash
awk '{print $1}' file.txt

7. File & Directory Management

find

bash
find /path/to/search -name "*.txt"

rsync

bash
rsync -avz /path/source/ user@remote_host:/path/destination/

tar

bash
tar -cvzf archive.tar.gz /path/to/archive/

8. System Information

bash
lsb_release -a
cat /etc/os-release
uname -a
lscpu
lsmem

9. System Monitoring

bash
top
htop
vmstat 1

10. Networking Commands

bash
netstat -a
netstat -at
netstat -lt
netstat -lu
netstat -au

• Install net-tools:

bash
sudo apt install net-tools

• Packet Analysis

bash
tcpdump -i eth0 -n

11. Shell Information

bash
echo $SHELL
ps -p $$

12. System Logs

bash
find / -name syslog
cd /var/log
cat syslog
cat syslog | less
cat syslog | grep "keyword"

13. User and Group Management

bash
useradd -D -s /bin/bash
useradd -m user_name
passwd user_name
usermod -aG sudo user_name
su - user_name
su - root
whoami
echo $USER
exit
sudo !!

• Groups

bash
groupadd docker
getent group docker
sudo usermod -aG docker $USER
groups user_name
cat /etc/group

14. Process Management

bash
ps
ps -f
ps -e
ps -e --forest
ps -u username
ps -p pid
ps aux
ps aux --sort=-%cpu
ps aux --forest
ps aux -l

15. Additional Useful Commands

Network Check

bash
ping google.com
ping -c 5 google.com

Web Requests

bash
curl https://www.google.com
curl -o file.txt https://www.google.com

Repeated Execution

bash
watch -n 10 date

Base64 Encoding

bash
echo "your_message" | base64
echo "encoded_message" | base64 --decode

Count Lines

bash
cat filename | wc -l

Aliases

bash
alias m=mkdir

End of Linux Tutorial