Master the 100 Most Essential Linux Commands for File Management, Networking, and Troubleshooting
This comprehensive guide collects the 100 most frequently used Linux commands, organized into ten practical modules—from basic file and directory operations to advanced network troubleshooting—each illustrated with common options, real‑world examples, and safety tips, making it a permanent reference for sysadmins and developers alike.
Overview
The article gathers the ~100 high‑frequency Linux commands that cover ten major usage scenarios, providing the most common options and concrete examples for each command.
1. File and Directory Operations
pwd– prints the current directory. pwd -P shows the physical path without symlinks. cd – change directory. Examples: cd /etc/sysconfig (absolute), cd .. (parent), cd - (previous directory). ls – list directory contents. Frequently used flags: -l (long), -lh (human‑readable sizes), -a (show hidden files), -lt (sort by modification time descending), -R (recursive). mkdir – create directories. mkdir -p a/b/c creates nested directories in one step. touch – create empty files or update timestamps. touch -t 202601011200 file.log sets a specific time. cp – copy files or directories. cp -a /etc /backup preserves attributes; cp -i prompts before overwriting. mv – move or rename. mv -u *.log /archive moves only newer files. rm – delete files. rm -rf /path is dangerous; safety tip: alias rm='rm -i' or use trash-cli. rmdir – remove empty directories; rmdir -p a/b/c removes empty parent directories recursively.
2. File Viewing and Editing
cat– display file contents; options -n (line numbers), -b (non‑blank line numbers), -A (show non‑printable characters). less / more – paginate large files; less supports searching ( /keyword) and real‑time follow ( F). head / tail – view file start or end; tail -f follows logs, tail -n +20 shows from line 20 onward. vi / vim – text editors. Basic modes: command (default), insert ( i), command‑line ( :). Common commands: :w (save), :q (quit), :wq (save & quit), dd (delete line), yy (yank), p (paste). sed – stream editor for batch replacements. Example: sed -i 's/old/new/g' file.txt replaces all occurrences in place. awk – powerful text processor. Example: awk '{print $1}' access.log prints the first column; awk -F: '{print $1}' /etc/passwd uses ':' as delimiter. wc – count lines, words, bytes. wc -l file.txt counts lines.
3. Text Search and Processing
grep– search patterns. Flags: -i (ignore case), -n (show line numbers), -v (invert match), -c (count), -r (recursive). sort and uniq – sort output and remove duplicates. sort -n file.txt | uniq -c counts occurrences. diff / patch – compare files/directories and apply patches. tr – translate or delete characters. Example: echo "hello" | tr a-z A-Z converts to uppercase. cut – extract columns. Example: cut -d: -f1 /etc/passwd gets the first field.
4. User and Permission Management
chmod– change file mode. Numeric example: chmod 755 file.sh; symbolic example: chmod u+x script.sh. Recommended defaults: 644 for regular files, 755 for executables, 600 for private keys. chown – change owner/group. Example: chown alice:dev file (recursive with -R). useradd, usermod, userdel – manage user accounts. Example: useradd -m -s /bin/bash bob creates a home directory and sets the shell. groupadd, gpasswd – manage groups. id, who, w, last – query user information.
5. System Monitoring and Process Management
ps– list processes. ps aux shows all processes; ps -ef alternative format. top / htop – real‑time process monitor. P sorts by CPU, M by memory. kill, pkill, killall – terminate processes. Prefer kill PID (SIGTERM) before kill -9 PID (SIGKILL). free – memory usage; focus on the available column. uptime – system load; load average should stay below the number of CPU cores. uname, hostname – kernel and host information. date, cal – date and calendar. dmesg – kernel ring buffer; useful for boot‑time issues. lsof – list open files; lsof -i :80 finds processes using port 80. strace – trace system calls of a process.
6. Disk and Filesystem
df– filesystem space; alert when usage exceeds 80%. du – directory size; du -sh /var/log shows total size. lsblk – list block devices. mount / umount – mount and unmount filesystems. fdisk / parted – partition disks (dangerous, backup first). mkfs – create filesystems (e.g., mkfs.ext4 /dev/sdb1).
7. Compression and Archiving
tar– archive and compress. Common flags: -c (create), -x (extract), -z (gzip), -j (bzip2), -J (xz), -v (verbose), -f (file name). zip / unzip – zip archives; -e adds a password. gzip / gunzip, bzip2, xz – compress single files.
8. Network‑Related Commands
ping– test reachability; -c 4 limits count. curl – HTTP client. Examples: curl -I https://example.com (headers only), curl -L (follow redirects), curl -v (verbose). wget – download files; -c resumes. ssh – remote login; port forwarding with -L or -R. scp – secure copy; -r for directories. rsync – incremental sync. Typical usage: rsync -avh /src/ user@host:/dst/; --delete mirrors deletions. netstat / ss – show listening sockets and connections. ifconfig / ip – network interface configuration. traceroute / mtr – route tracing; mtr -r -c 100 produces a report. nslookup / dig / host – DNS queries. telnet / nc – test TCP ports. iptables – firewall rule management; example to allow HTTP: iptables -A INPUT -p tcp --dport 80 -j ACCEPT. tcpdump – packet capture; -w capture.pcap saves to file.
9. Package Management
yum/ dnf (RHEL/CentOS) – install, remove, update packages. apt (Debian/Ubuntu) – similar functions. rpm – low‑level package queries on older RHEL systems.
10. Useful Utilities and Tips
history– command history; Ctrl+R searches. alias – create shortcuts, e.g., alias ll='ls -l' or alias rm='rm -i'. crontab – schedule recurring tasks; use absolute paths. systemctl – manage systemd services (start, stop, enable, view logs). screen and tmux – terminal multiplexers for long‑running sessions. watch – repeat a command periodically, e.g., watch -n 2 "ls -lh /data".
Conclusion
Mastering these 100 high‑frequency commands equips you to handle roughly 90% of everyday Linux tasks, from basic file manipulation to complex network troubleshooting and system administration. Keep this guide bookmarked and refer to it whenever a command is forgotten; repeated use will turn these examples into muscle memory.
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.
AI Agent Super App
AI agent applications, installation, large-model testing, computer fundamentals, IT operations and maintenance exchange, network technology exchange, Linux learning
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.
