Ultimate Linux Command-Line Guide: Detailed Usage of Common Commands
This comprehensive guide covers essential Linux command‑line tools for file management, disk usage, networking, and system monitoring, providing clear syntax, option explanations, and practical examples for commands such as find, cat, chmod, tar, du, netstat, top, and many more.
File Management Commands
The find command searches for files and directories using a path, expression, and optional action, e.g., find /var/log -name "*.log" -size +10M -delete. The cat command displays or concatenates files, with options like -n to number lines and -E to show end‑of‑line markers. touch creates empty files or updates timestamps, for example touch -c -t 202301011200 newfile.txt. The which command locates executables in $PATH, e.g., which bash. expr evaluates arithmetic and string expressions, such as expr 10 + 20. The chmod command changes file permissions using symbolic ( chmod u+x file) or octal ( chmod 755 file) modes.
Text Processing Utilities
lessprovides interactive paging with navigation keys and search patterns. awk processes text with pattern‑action statements, for instance awk -F',' '{print $1,$3}' data.csv. sed performs stream editing, such as sed -n '2,5p' file.txt to print lines 2‑5. tr translates or deletes characters, e.g., cat file | tr 'a‑z' 'A‑Z'.
Archive and Compression Tools
tarcreates and extracts archives: tar -cvf archive.tar file1 dir/ and tar -xvf archive.tar. zip compresses multiple files ( zip -r archive.zip dir/) and unzip extracts them. gzip compresses single files ( gzip file.txt) and gzip -d file.txt.gz decompresses.
Disk and Filesystem Utilities
dureports disk usage with human‑readable output ( du -h /home/user) and total summarisation ( du -sh *). df shows filesystem space, e.g., df -h. stat displays inode information: stat /etc/passwd.
Network Configuration and Monitoring
ifconfigconfigures network interfaces ( ifconfig eth0 up, ifconfig eth0 192.168.1.10 netmask 255.255.255.0). telnet opens remote sessions ( telnet 192.168.0.7). netstat lists socket statistics ( netstat -tunap) and ss provides faster socket details ( ss -tuln). ping (not shown in the source but commonly used) tests connectivity.
System Process and Resource Tools
psdisplays processes ( ps aux), while top offers a real‑time view of CPU, memory, and load averages ( top -d 2). kill terminates processes ( kill -9 1234) and free reports memory usage ( free -h). dstat aggregates CPU, disk, network, and memory statistics ( dstat -c -d -n). vmstat and iostat provide additional performance metrics.
Remote Access and Transfer
sshsecurely logs into remote hosts ( ssh user@host -p 2222) with options for identity files, compression, and port forwarding. scp (not listed but related) copies files over SSH. curl and wget retrieve web resources, e.g., curl -O https://example.com/file.tar.gz and wget -c http://example.com/file.iso.
Performance Profiling
The perf suite records hardware events, such as perf stat ls or perf stat -e cycles,instructions ./program. watch repeatedly runs a command and updates the display, for example watch -n 1 free -h to monitor memory.
Shell Variables and Scripting
Variables are assigned without spaces ( var=value) and accessed with $var or ${var}. Integer variables can be declared with declare -i count=10. Arrays are created with arr=(one two three) and associative arrays with declare -A map. Special parameters like $0, $#, and $? provide script name, argument count, and exit status respectively.
Additional Utilities
Manual pages are viewed with man ( man ls). The variable section explains setting, reading, making read‑only, and unsetting variables, as well as string manipulation techniques.
Linux Tech Enthusiast
Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.
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.
