Essential Linux Command Line Cheat Sheet for Beginners (70+ Commands)
This guide compiles around 70 essential Linux command‑line utilities, covering navigation, file manipulation, text processing, permission handling, user management, archiving, disk operations, and system monitoring, with clear examples and practical tips for newcomers to master the shell.
Part 1: Basic navigation commands
pwd – prints the current working directory. pwd Output example: /home/user/Documents ls – lists files and directories. Use -l for detailed view and -a to include hidden files. ls -l cd – changes the current directory. cd without arguments returns to the home directory.
cd ~
cd ~/Desktop
cd ..
cd -clear – clears the terminal screen.
clearPart 2: File operations
touch – creates an empty file. touch newfile.txt mkdir – creates a directory. Use -p for recursive creation.
mkdir my_folder
mkdir -p parent_folder/child_foldercp – copies files or directories. Add -r for recursive copy.
cp file.txt backup.txt
cp -r my_folder my_folder_copymv – moves or renames files.
mv old_name.txt new_name.txt
mv file.txt /home/user/Documents/
mv file.txt /home/user/Documents/new_name.txtrm – removes files or directories. Use -r for recursive deletion and -f to force.
rm file.txt
rm -r my_folder
rm -rf my_folderPart 3: Text viewing and processing
cat – displays file contents; can concatenate multiple files.
cat file1.txt
cat file1.txt file2.txt > combined.txt
cat -n combined.txttac – displays file contents in reverse order. tac file.txt less and more – paginated viewers. less supports forward/backward scrolling and searching.
more file.txt
less file.txthead and tail – show the beginning or end of a file. Use -n to specify line count; -f follows a growing file.
head -n 5 file.txt
tail -n 8 file.txt
tail -f file.txtgrep – searches text using patterns. Common options: -i (ignore case), -n (line numbers), -c (count), -l (list filenames), -v (invert match), -R (recursive).
grep "error" logfile.txt
grep -i "error" logfile.txt
grep -n "error" logfile.txt
grep -R "keyword" /path/to/dir
grep -v "error" logfile.txt
grep -E "error|fail" logfile.txt
grep -c "error" logfile.txt
grep -l "error" *.txtfind – locates files by name, type, size, time, etc., and can execute actions on matches.
find . -name "file.txt"
find /path/to/dir -iname "*test*"
find . -type d
find . -size +10M
find . -mtime -7
find . -name "*.log" -exec rm {} \;sed – stream editor for in‑place text transformations.
sed 's/old/new/g' file.txt
sed -i 's/old/new/g' file.txt
sed '/unwanted/d' file.txt
sed -n '5p' file.txt
sed 's/$/ END/' file.txtawk – powerful pattern‑scanning and processing language.
awk '{print $1, $3}' file.txt
awk '/error/ {print}' file.txt
awk '$3 > 100 {print}' file.txt
awk -F ',' '{print $2}' file.csv
awk 'END {print NR}' file.txt
awk '{sum += $3} END {print sum}' file.txtwc – counts lines, words, and bytes.
wc -l file.txt
wc -w file.txtPart 4: Permission management
chmod – changes file mode (permissions). Numeric (e.g., 755) and symbolic ( +x) forms are supported; -R applies recursively.
chmod 755 script.sh
chmod 600 secret.txt
chmod -R +x /path/to/dir
chmod +x script.sh
chmod -w readonly.txt
chmod g+w shared_file.txt
chmod u=rwx,g=rx,o= script.shchown – changes file owner and optionally group. Use -R for recursion.
sudo chown user1 file.txt
sudo chown user1:group1 file.txt
sudo chown -R user1:group1 /path/to/dirchgrp – changes the group ownership of a file or directory.
sudo chgrp group1 file.txt
sudo chgrp -R group1 /path/to/dirPart 5: User management
adduser – creates a new system user and its home directory. sudo adduser john deluser – removes a user but leaves the home directory untouched. sudo deluser john passwd – changes a user's password; prepend sudo to modify another user.
passwd
sudo passwd usernameid – shows UID, GID, and group memberships.
id
id usernamewhoami , who , w – display logged‑in users and their activity.
whoami
who
wPart 6: Archiving and compression
tar – creates and extracts archives; add -z for gzip compression.
tar -cvf archive.tar file1 file2
tar -xvf archive.tar
tar -czvf archive.tar.gz file1 file2
tar -xzvf archive.tar.gzzip / unzip – compresses and extracts ZIP files. Use -r to include directories.
zip archive.zip file1 file2 -r dir
unzip archive.zipgzip / gunzip – compresses or decompresses single files. -k keeps the original.
gzip file.txt
gzip -k file.txt
gunzip file.txt.gz
gunzip -k file.txt.gzPart 7: Disk and device management
mount – attaches a filesystem to a directory; umount detaches it.
sudo mount /dev/sdb1 /mnt
sudo umount /mntfsck – checks and repairs filesystem inconsistencies. Common flags: -y (auto‑repair), -n (no‑repair), -f (force).
sudo fsck /dev/sda1
sudo fsck -f /dev/sda1
sudo fsck -n /dev/sda1
sudo fsck -y /dev/sda1lsblk – lists block devices and their partitions.
lsblk -a
lsblk -fPart 8: System information and monitoring
hostname – shows or sets the system's host name.
hostname
sudo hostname new-hostname
sudo hostnamectl set-hostname new-hostnameuname – prints kernel and system information.
uname
uname -a
uname -s
uname -r
uname -mtop – interactive view of CPU and memory usage; press q to quit. Use P to sort by CPU and M by memory. top ps – snapshots current processes; combine with grep to filter.
ps aux
ps aux | grep process_namekill – terminates processes by PID; -9 forces termination.
kill 12345
kill -9 12345free – displays memory usage; -h for human‑readable, -s for continuous monitoring.
free
free -h
free -s 1df – reports filesystem disk space usage; -h makes it human‑readable.
df
df -h
df -h /path/to/dirdu – estimates file and directory space usage; -h for readability, -s for summary.
du
du -h
du -sh
du -h /path/to/dirConclusion
These commands form the core toolkit for everyday Linux work, covering navigation, file handling, text processing, permissions, user administration, archiving, device control, and system monitoring. Mastering them equips beginners with the confidence to tackle real‑world tasks and lays a solid foundation for deeper Linux expertise.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
