File & Directory Management
ls
– List directory contentsls -l
(detailed list),ls -a
(show hidden files)
cd
– Change directorycd ~
(home),cd ..
(up one level)
pwd
– Print working directory
cp
– Copy files/dirscp -r
(recursive for directories)
mv
– Move/rename files
rm
– Remove filesrm -rf
(force delete dirs – use cautiously!)
mkdir
– Create directorymkdir -p
(create nested dirs)
rmdir
– Remove empty directory
touch
– Create empty file/update timestamps
cat
– Display file contentcat > file.txt
(create file)
nano
/vim
– Text editorsless
/more
– View files page-by-page
head
– Show first 10 lines of a filehead -n 20
(show 20 lines)
tail
– Show last 10 linestail -f
(follow log updates)
ln
– Create linksln -s
(symbolic link)find
– Search files/dirsfind / -name "*.log"
locate
– Find files quickly (uses database)
chmod
– Change permissionschmod 755 file
,chmod +x script.sh
chown
– Change ownershipchown user:group file
stat
– Show file details
System Information
uname
– System infouname -a
(all details)df
– Disk spacedf -h
(human-readable)
du
– Directory space usagedu -sh /dir
top
/htop
– Real-time process monitor
free
– Memory usagefree -m
(MB units)uptime
– System uptimewhoami
– Current userhostname
– System hostnamelscpu
– CPU informationlsblk
– List block devices
Process Management
ps
– List processesps aux
(detailed list)
kill
– Terminate processkill -9 PID
(force kill)
killall
– Kill processes by namekillall nginx
bg
– Send process to backgroundfg
– Bring process to foregroundjobs
– List background jobsnice
– Set process priorityrenice
– Change priority of running processpkill
– Kill processes by patternpgrep
– Find PIDs by name
Networking
ping
– Test connectivityping google.com
ifconfig
/ip
– Network interfaces (useip
for modern systems)
netstat
– Network statsnetstat -tulpn
(open ports)ss
– Socket statistics (replacesnetstat
)dig
/nslookup
– DNS queriestraceroute
– Network path tracingwget
– Download fileswget -c
(resume download)
curl
– Transfer data via URLscurl -O file_url
ssh
– Remote loginssh user@host
scp
– Secure file copyscp file.txt user@host:/path
rsync
– Sync filesrsync -avz source/ dest/
iptables
– Firewall rulesnmcli
– NetworkManager CLI toolhost
– DNS lookup
whois
– Domain registration info
User & Permission Management
sudo
– Execute as superusersu
– Switch usersu - username
useradd
– Add useruseradd -m johndoe
passwd
– Change passwordusermod
– Modify userusermod -aG sudo johndoe
userdel
– Delete usergroupadd
– Create groupid
– User/group infovisudo
– Edit sudoers filelast
– Show login history
Package Management
apt
– Debian/Ubuntu packagesapt install package
yum
– RHEL/CentOS (older)dnf
– RHEL/CentOS (modern)pacman
– Arch Linuxpacman -S package
zypper
– openSUSEsnap
– Universal packagessnap install package
dpkg
– Debian package installerdpkg -i package.deb
rpm
– RPM package manager
Text Processing
grep
– Search text patternsgrep -i "error" log.txt
(case-insensitive)
sed
– Stream editorsed 's/old/new/g' file.txt
awk
– Text processing languageawk '{print $1}' file.txt
cut
– Extract columnscut -d',' -f1 data.csv
sort
– Sort linessort -nr
(numeric reverse)
uniq
– Remove duplicatesuniq -c
(count repeats)
wc
– Word/line countwc -l file.txt
diff
– Compare filesdiff file1.txt file2.txt
tr
– Translate characterstr 'a-z' 'A-Z'
tee
– Redirect to file and screenls | tee output.txt
Compression/Archiving
tar
– Archive filestar -czvf archive.tar.gz /dir
gzip
/gunzip
– Compress/decompress .gz files
zip
/unzip
– .zip archivesbzip2
/bunzip2
– .bz2 compression7z
– 7-Zip utility
Disk Management
fdisk
– Partition disks
mount
/umount
– Attach/detach filesystemslsusb
/lspci
– List hardware devicesmkfs
– Format diskmkfs.ext4 /dev/sdb1
fsck
– Filesystem checkdd
– Disk/image operationsdd if=/dev/sda of=backup.img
Terminal Management
clear
– Clear terminal
history
– Command history!123
(rerun command #123)alias
– Create shortcutsalias ll='ls -alF'
source
– Reload configssource ~/.bashrc
exit
– Close terminaltmux
/screen
– Terminal multiplexers
Scripting & Automation
cron
– Schedule tasks
Edit withcrontab -e
at
– Run command once at a time
echo
– Print textecho $PATH
printf
– Formatted outputtest
– Conditional checks
Used in scripts:if test -f file.txt; then...
Advanced Tools
strace
– Trace system callslsof
– List open fileslsof -i :80
journalctl
– Systemd logsjournalctl -u nginx
systemctl
– Manage servicessystemctl start nginx
vmstat
– Virtual memory statsiostat
– Disk I/O statssar
– System activity reporternc
/netcat
– Network Swiss Army knifetcpdump
– Network packet captureopenssl
– SSL/TLS toolkit
Pro Tips
- Use
man command
(e.g.,man ls
) to read manuals. - Combine commands with pipes:
cat file.txt | grep "error" | sort
- Redirect output:
>
(overwrite),>>
(append),2>
(stderr). - Wildcards:
*
(any chars),?
(single char),[a-z]
(ranges).
Practice these in a safe environment first! Commands like rm -rf /
or dd
can cause irreversible data loss.