What Is the Linux Command Line?
The Linux command line (terminal, shell, or CLI) is the text-based interface for interacting with a Linux or macOS system. Developers who master the command line work dramatically faster — automating repetitive tasks, managing servers remotely via SSH, debugging production issues, and processing large datasets efficiently. Most server environments run Linux, making terminal proficiency essential for any backend developer or DevOps engineer.
How to Use This Linux Commands Guide
- Open your terminal — Terminal on macOS, or any terminal emulator on Linux.
- Try each command — Most are safe to run; destructive commands are clearly labeled.
- Use the man pages —
man <command>displays the full manual for any command. - Build aliases — Add frequently used long commands as short aliases in your
~/.bashrcor~/.zshrc. - Practice in a safe directory — Create a
~/practicefolder to experiment.
Essential Linux Commands by Category
File System Navigation
pwd # Print working directory
ls -la # List all files with details
cd /path/to/dir # Change directory
cd ~ # Go to home directory
cd - # Go to previous directory
find . -name "*.js" # Find files by name pattern
File Operations
cp source dest # Copy file
cp -r source/ dest/ # Copy directory recursively
mv source dest # Move or rename
rm file # Delete file
rm -rf directory/ # Delete directory (careful!)
mkdir -p path/to/dir # Create nested directories
touch file.txt # Create empty file or update timestamp
Viewing File Contents
cat file.txt # Print entire file
less file.txt # Page through file (q to quit)
head -n 20 file.txt # First 20 lines
tail -n 50 file.txt # Last 50 lines
tail -f logfile.log # Follow live log output
grep "pattern" file.txt # Search for pattern in file
grep -r "pattern" ./src/ # Recursive search
Permissions and Ownership
chmod 755 script.sh # Set permissions (rwxr-xr-x)
chmod +x script.sh # Make executable
chown user:group file # Change owner
ls -la # View permissions
Process Management
ps aux # List all processes
top # Interactive process viewer
htop # Better interactive viewer (install first)
kill <PID> # Send SIGTERM to process
kill -9 <PID> # Force kill (SIGKILL)
lsof -i :3000 # Find process using port 3000
<command> & # Run in background
nohup <command> & # Run immune to hangup
Networking
curl -I https://example.com # HTTP HEAD request
wget https://example.com/file # Download file
ssh user@host # SSH into remote server
scp file.txt user@host:~/ # Copy file to remote
netstat -tlnp # List listening ports
ss -tlnp # Modern alternative to netstat
Use Cases
Server Debugging
When an application isn't responding on a server, use lsof -i :PORT to check if the process is listening, tail -f /var/log/app.log to watch live logs, and ps aux | grep appname to confirm the process is running.
Log Analysis
Combine grep, sort, uniq, and awk to analyze logs: grep "ERROR" app.log | sort | uniq -c | sort -rn gives a frequency-sorted list of unique error messages.
aiforeverthing.com — Developer utilities, no signup required.
Frequently Asked Questions
How do I run a command as root in Linux?
Prefix the command with sudo: sudo apt install nginx. You'll be prompted for your password. Avoid running your entire session as root — use sudo only when necessary.
How do I search for text inside files recursively?
Use grep -r "search term" /path/to/directory. Add -l to list only filenames, -n to show line numbers, and -i for case-insensitive search. ripgrep (rg) is a faster modern alternative.
What does chmod 755 mean?
Permissions are represented as three digits for owner, group, and others. Each digit is a sum: 4=read, 2=write, 1=execute. So 755 means owner has rwx (7), group has r-x (5), others have r-x (5). Scripts typically use 755; sensitive files use 600 (owner read/write only).
How do I keep a process running after closing SSH?
Use nohup command &, screen, or tmux to keep processes running after disconnecting. For production services, use systemd (systemctl enable myservice) to manage processes that start automatically and restart on failure.
What is the difference between > and >> for redirecting output?
> redirects output to a file, overwriting it if it exists. >> appends to the file. Use 2>&1 to redirect both stdout and stderr: command > output.log 2>&1.
Recommended Hosting for Developers
- Hostinger — From $2.99/mo. Excellent for static sites and Node.js apps.
- DigitalOcean — $200 free credit for new accounts. Best for scalable backends.
- Namecheap — Budget-friendly shared hosting with free domain.