Linux is a command-line powerhouse, and knowing how to interact with it efficiently is essential for system administrators, developers, and even regular users. This comprehensive guide covers the top Linux commands, grouped by purpose, with usage examples, practical tips, and deeper insights. ๐ File and Directory Management Command Description Sample Usage ls Lists directory contents…
Linux is a command-line powerhouse, and knowing how to interact with it efficiently is essential for system administrators, developers, and even regular users. This comprehensive guide covers the top Linux commands, grouped by purpose, with usage examples, practical tips, and deeper insights.
๐ File and Directory Management
Command
Description
Sample Usage
ls
Lists directory contents
ls -alh
cd
Changes the working directory
cd /etc
pwd
Displays current working directory
pwd
mkdir
Creates a new directory
mkdir projects
rmdir
Removes an empty directory
rmdir temp
rm
Deletes files or directories
rm -rf myfolder
touch
Creates an empty file
touch notes.txt
cp
Copies files or directories
cp file.txt backup.txt
mv
Moves or renames files
mv file.txt archive/
find
Searches files in directory hierarchies
find . -name "*.log"
cat
Concatenates and prints file content
cat /etc/hosts
nano, vim
Terminal-based file editors
nano file.txt
๐ Text Searching & Processing
Command
Purpose
Sample Usage
grep
Search for patterns in files
grep "error" /var/log/syslog
awk
Powerful text processing
awk '{print $1}' data.txt
sed
Stream editor for editing text
sed 's/foo/bar/g' file.txt
cut
Extract columns from files
cut -d':' -f1 /etc/passwd
sort
Sort lines in text files
sort -n file.txt
head / tail
View file beginnings or ends
head -n 10 log.txt
wc
Count lines, words, characters
wc -l file.txt
diff / cmp / comm
Compare files
diff file1 file2
less
Paginate output
less /var/log/dmesg
๐งโ๐ป User and Permission Management
Command
Purpose
Example
adduser, useradd
Add new user
useradd alice
passwd
Change password
passwd alice
usermod
Modify user account
usermod -aG sudo alice
chage
Set password expiry info
chage -l alice
groups
View user groups
groups alice
id
Show UID, GID, and groups
id alice
chown
Change ownership
chown root:root file.txt
chmod
Set permissions
chmod 755 script.sh
sudo
Run command with elevated rights
sudo apt update
๐ฅ๏ธ System Monitoring and Process Management
Command
Description
Example
top / htop
Real-time system usage
top, htop
ps
View active processes
ps aux
kill / killall
Terminate processes
kill 1234, killall nginx
uptime
Show system uptime
uptime
free
Display memory usage
free -h
vmstat, iostat, lsof
View memory, I/O, open files
vmstat 1, iostat, lsof
strace
Trace syscalls of a process
strace -p 1234
systemctl
Manage system services
systemctl status nginx
journalctl
View system logs
journalctl -xe
๐ Networking Essentials
Command
Purpose
Usage
ping
Test connectivity
ping google.com
ifconfig / ip a
Network interfaces
ip a
netstat / ss
Socket stats
netstat -tuln
wget, curl
Download files
wget URL, curl -O URL
ssh
Secure remote login
ssh user@host
scp / rsync
Copy files remotely
scp file user@host:~/
ftp, sftp
File transfer protocols
sftp user@host
traceroute
Trace packet route
traceroute google.com
iptables / ufw
Firewall configuration
ufw allow 22
๐พ Disk and File System Utilities
Command
Task
Usage
df
Disk usage
df -h
du
Directory/file size
du -sh folder/
mount, umount
Mount/unmount devices
mount /dev/sdb1 /mnt
tar
Archive/unarchive
tar -xvf archive.tar
zip, unzip
Compress/extract
zip archive.zip file.txt
dd
Clone disks, create bootable USB
dd if=/dev/sda of=/dev/sdb
โ๏ธ Shell Productivity & Shortcuts
Command
Function
Example
alias
Create shortcut
alias ll='ls -alF'
unalias
Remove alias
unalias ll
history
View command history
history
clear
Clear terminal
clear
cal
View calendar
cal
date
Display current date/time
date
sleep, time, watch
Wait, time, repeat commands
sleep 5, time ls, watch -n 5 df -h
๐ ๏ธ Common Troubleshooting Tips
๐ Command Not Found: Use which <cmd> to locate, or install via sudo apt install <package>.
๐ Permission Denied: Use sudo or fix ownership via chown/chmod.
โ ๏ธ Conflicts/Errors: Check logs with journalctl, dmesg, or tail -f /var/log/syslog.
๐ฅ Performance Bottlenecks: Profile with top, htop, iostat, vmstat.
๐ Pro Tips
Use man <command> or whatis <command> to discover more about any utility.
Combine commands with pipes (|) and redirection (>, >>) for more powerful workflows.
Use ~/.bashrc or ~/.zshrc to store aliases, functions, and environment variables.
The openSUSE Project has officially announced the public beta release of openSUSE Leap 16, marking a significant milestone in the evolution of this enterprise-grade Linux distribution. This beta introduces the new Agama installer and integrates the robust Linux 6.12 Long-Term Support (LTS) kernel, offering users a glimpse into the future of openSUSE. ๐ What’s New…