Linux Command Line: The Complete Mastery Guide
The Linux command line (Terminal) is one of the most powerful tools in computing. Whether you are a developer, system administrator, DevOps engineer, or ethical hacker, mastering Linux commands is essential. This guide covers everything you need, from basic commands to advanced system management.
Table of Contents
1. What is the Linux Command Line?
The Linux Command Line (CLI) allows you to interact with the operating system using text-based commands instead of a graphical interface. It is the gold standard for performance, precision, and automation.
Speed
Outperform any GUI
Automation
Bash & Shell Scripting
Cloud
Standard for Server Mgmt
Security
Granular System Control
2. Terminal Basics
Command Structure:
command [options] [arguments]Example: List files in long format
$ ls -l /home/user3. File & Directory Commands
Navigation & Listing
$ pwd # Print working directory
$ ls # List files
$ ls -la # List all including hidden
$ cd folder # Change directory
$ cd .. # Go backCreating & Managing
$ touch file.txt # Create empty file
$ mkdir folder # Create folder
$ cp file1 file2 # Copy file
$ mv oldname newname # Rename/Move
$ rm -rf folder # ⚠ Delete folder recursively4. File Viewing & Editing
$ cat file.txt # Output entire file
$ head -n 5 file.txt # First 5 lines
$ tail -f log.log # Follow log file in real-time
$ nano file.txt # Simple text editor
$ vim file.txt # Advanced text editor5. Permissions & Ownership
Linux security is built on permissions (Read, Write, Execute).
$ chmod +x script.sh # Make script executable
$ chmod 755 file.txt # Set specific permissions
$ chown user:group file # Change owner and group6. Search & Find
$ grep "error" app.log # Search for text in file
$ find /etc -name "*.conf" # Find files by name
$ which python # Locate command path8. Networking Commands
$ ping google.com # Check connectivity
$ ip a # Show IP addresses
$ curl -I google.com # Fetch HTTP headers
$ wget url # Download file9. Process Management
$ top # Monitor system resources
$ ps aux # List all running processes
$ kill -9 1234 # Force kill process by PID
$ pkill process_name # Kill by name10. Disk & System Information
$ df -h # Disk space usage (human readable)
$ du -sh . # Total size of current directory
$ free -h # Memory (RAM) usage
$ uptime # System run time11. Package Management
# Debian/Ubuntu
$ sudo apt update && sudo apt install git
# Red Hat/CentOS
$ sudo yum install git15. Linux Command Cheat Sheet
| Command | Description |
|---|---|
| ls | List files |
| cd | Change directory |
| pwd | Current directory |
| cp | Copy files |
| mv | Move files |
| rm | Delete files |
| chmod | Change permissions |
| chown | Change owner |
| grep | Search text |
| find | Find files |
| tar | Archive |
| top | Process monitor |
| df | Disk usage |
| free | Memory |
| ssh | Remote login |
Conclusion
This guide is your foundation for Linux mastery. The best way to learn is by doing—open your terminal, try these commands, and explore the system. As you get comfortable, you'll find the CLI far more efficient than any graphical tool!