Surviving the Linux Terminal
Published on September 15, 2025
Surviving the Linux Terminal
As a developer, sooner or later you’ll find yourself working on a Linux server. Whether to deploy an application, debug a production issue, or configure services, you’ll need to know how to navigate and work in the Linux terminal.
The Linux terminal can be intimidating at first, but once you master the essential commands, it becomes one of your most powerful tools.
In this guide, I’ll share the essential commands every developer should know to survive (and thrive) in the Linux terminal.
Basic navigation
pwd - Where am I?
pwd
# /home/sebastian/projects
Shows the current directory.
ls - List files
# List files
ls
# List with details
ls -l
# List all (including hidden)
ls -la
# List with human-readable size
ls -lh
# List sorted by date
ls -lt
# List directories only
ls -d */
cd - Change directory
# Go to home
cd ~
cd
# Go to parent directory
cd ..
# Go to parent of parent
cd ../..
# Go to previous directory
cd -
# Go to absolute path
cd /var/www/html
# Go to relative path
cd projects/my-app
find - Search for files
# Search by name
find . -name "*.js"
# Search by type
find . -type f -name "*.log"
# Search directories
find . -type d -name "node_modules"
# Search by size (over 100MB)
find . -size +100M
# Search and run command
find . -name "*.tmp" -delete
File manipulation
cat - View content
# View full file
cat file.txt
# View with line numbers
cat -n file.txt
# View multiple files
cat file1.txt file2.txt
less / more - View large files
# View file (navigable)
less large-file.log
# Navigation in less:
# - Space: next page
# - b: previous page
# - /text: search
# - q: quit
head / tail - View start/end
# First 10 lines
head file.txt
# First 20 lines
head -n 20 file.txt
# Last 10 lines
tail file.txt
# Last 20 lines
tail -n 20 file.txt
# Follow file in real time (useful for logs)
tail -f /var/log/nginx/access.log
cp - Copy
# Copy file
cp source.txt destination.txt
# Copy directory recursively
cp -r source/ destination/
# Copy preserving permissions
cp -p file.txt backup/
# Copy with confirmation
cp -i source.txt destination.txt
mv - Move/Rename
# Move file
mv source.txt /destination/
# Rename
mv old-name.txt new-name.txt
# Move multiple files
mv file1.txt file2.txt destination/
rm - Delete
# Delete file
rm file.txt
# Delete directory
rm -r directory/
# Force delete (no confirmation)
rm -rf directory/
# Delete with confirmation
rm -i file.txt
# ⚠️ WARNING: rm -rf / is destructive
mkdir - Create directories
# Create directory
mkdir new-directory
# Create nested directories
mkdir -p parent/child/grandchild
# Create with permissions
mkdir -m 755 directory
Text editors
nano - Simple editor
# Open file
nano file.txt
# Shortcuts:
# Ctrl + O: Save
# Ctrl + X: Exit
# Ctrl + W: Search
# Ctrl + K: Cut line
vim - Powerful editor
# Open file
vim file.txt
# Vim modes:
# - Normal (default): navigation
# - Insert: press 'i' to type
# - Command: press ':' for commands
# Essential commands:
# i: enter insert mode
# Esc: exit insert mode
# :w: save
# :q: quit
# :wq: save and quit
# :q!: quit without saving
# /text: search
# dd: delete line
# yy: copy line
# p: paste
Permissions and users
chmod - Change permissions
# Numeric permissions
chmod 755 file.txt
# 7 (owner): rwx (read, write, execute)
# 5 (group): r-x (read, execute)
# 5 (others): r-x (read, execute)
# Symbolic permissions
chmod u+x file.txt # Add execute to user
chmod g-w file.txt # Remove write from group
chmod o+r file.txt # Add read to others
chmod a+x script.sh # Add execute to all
# Recursive
chmod -R 755 directory/
chown - Change owner
# Change owner
chown user file.txt
# Change owner and group
chown user:group file.txt
# Recursive
chown -R user:group directory/
whoami / id - User information
# Current user
whoami
# Detailed information
id
# Switch to another user
su username
# Switch to root
sudo su
Processes and services
ps - Processes
# All processes
ps aux
# Current user's processes
ps
# Process tree
ps auxf
# Find process
ps aux | grep nginx
top / htop - Process monitor
# Interactive monitor
top
# Enhanced version (if installed)
htop
# Shortcuts in top:
# q: quit
# k: kill process
# M: sort by memory
# P: sort by CPU
kill - Terminate processes
# Terminate process (PID)
kill 1234
# Force terminate
kill -9 1234
# Terminate by name
pkill nginx
# Terminate all processes of a user
killall -u username
systemctl - System services
# Service status
systemctl status nginx
# Start service
sudo systemctl start nginx
# Stop service
sudo systemctl stop nginx
# Restart service
sudo systemctl restart nginx
# Reload configuration
sudo systemctl reload nginx
# Enable on boot
sudo systemctl enable nginx
# Disable on boot
sudo systemctl disable nginx
# List services
systemctl list-units --type=service
Network and connectivity
ping - Test connectivity
# Ping server
ping google.com
# Ping with limit
ping -c 4 google.com
curl - Data transfer
# GET request
curl https://api.example.com/data
# POST request
curl -X POST https://api.example.com/data \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
# Save response
curl -o output.txt https://example.com/file
# Follow redirects
curl -L https://example.com
# Headers only
curl -I https://example.com
# Verbose
curl -v https://example.com
wget - Download files
# Download file
wget https://example.com/file.zip
# Recursive download
wget -r https://example.com/
# Continue interrupted download
wget -c https://example.com/large-file.zip
netstat / ss - Network connections
# Active connections
netstat -tulpn
# Modern version
ss -tulpn
# Listening on specific port
netstat -tulpn | grep :80
# Established connections
ss -tn
Logs and debugging
journalctl - System logs
# View system logs
sudo journalctl
# Specific service logs
sudo journalctl -u nginx
# Recent logs
sudo journalctl -n 50
# Follow logs in real time
sudo journalctl -f
# Logs since date
sudo journalctl --since "2026-01-27 10:00:00"
# Logs until date
sudo journalctl --until "2026-01-27 12:00:00"
tail -f - Follow logs
# Follow log in real time
tail -f /var/log/nginx/access.log
# Follow multiple files
tail -f /var/log/nginx/*.log
# Follow with initial line count
tail -n 100 -f /var/log/nginx/access.log
grep - Search in files
# Search text
grep "error" file.log
# Case-insensitive search
grep -i "error" file.log
# Recursive search
grep -r "error" /var/log/
# Show line number
grep -n "error" file.log
# Invert (lines that DON'T contain)
grep -v "error" file.log
# Search with context
grep -C 5 "error" file.log # 5 lines before and after
# Regular expressions
grep -E "error|warning" file.log
Archives and compression
tar - Archive
# Create tar
tar -czf archive.tar.gz directory/
# Extract tar
tar -xzf archive.tar.gz
# List contents
tar -tzf archive.tar.gz
# Options:
# -c: create
# -x: extract
# -z: gzip
# -f: file
# -v: verbose
zip / unzip - Compress
# Compress
zip -r archive.zip directory/
# Decompress
unzip archive.zip
# List contents
unzip -l archive.zip
Environment variables and configuration
env - Environment variables
# View all variables
env
# View specific variable
echo $PATH
# Set variable
export MY_VAR="value"
# Temporary variable for command
MY_VAR="value" command
which / whereis - Find commands
# Command path
which node
# Path and documentation
whereis node
Useful shortcuts
History
# View history
history
# Search in history
history | grep "command"
# Run command from history
!123 # Runs command #123
# Last command
!!
# Last argument of previous command
!$
Aliases
# Create alias
alias ll='ls -lah'
alias ..='cd ..'
alias grep='grep --color=auto'
# View aliases
alias
# Permanent alias (add to ~/.bashrc)
echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrc
Redirection
# Redirect output
command > output.txt
# Append to file
command >> output.txt
# Redirect error
command 2> error.txt
# Redirect everything
command > output.txt 2>&1
# Pipe
command1 | command2
# Example
ps aux | grep nginx | head -5
Advanced commands
awk - Text processing
# Print column
ps aux | awk '{print $2}' # PID
# Filter and process
awk '/error/ {print $1, $2}' file.log
# Sum column
awk '{sum+=$1} END {print sum}' file.txt
sed - Stream editor
# Replace text
sed 's/old/new/g' file.txt
# Replace in file
sed -i 's/old/new/g' file.txt
# Delete lines
sed '/pattern/d' file.txt
# Print specific lines
sed -n '10,20p' file.txt
xargs - Execute with arguments
# Run command for each line
find . -name "*.log" | xargs rm
# With spaces in names
find . -name "*.log" -print0 | xargs -0 rm
Useful scripts for development
Check disk space
# Space used
df -h
# Space by directory
du -sh /var/* | sort -h
# Largest directories
du -h / | sort -rh | head -10
Resource monitoring
# CPU usage
top
# Memory usage
free -h
# I/O usage
iostat
Quick backup
# Directory backup
tar -czf backup-$(date +%Y%m%d).tar.gz /path/to/directory
# Database backup
mysqldump -u user -p database > backup-$(date +%Y%m%d).sql
Practical applications
These commands are essential for:
- Deployments: Configuring and deploying applications on servers
- Debugging: Analyzing logs and diagnosing issues
- Monitoring: Checking service status and resources
- Configuration: Configuring web servers, databases, and services
- Maintenance: Backups, updates, and file management
The Linux terminal can be intimidating, but these essential commands will give you the confidence to work on any Linux server.
My personal perspective
Mastering the Linux terminal isn’t optional for serious developers. These essential commands will allow you to:
- Navigate and manipulate files efficiently
- Debug production issues
- Monitor and manage services
- Automate common tasks
I’ve used these commands constantly on projects of all sizes. The Linux terminal can be intimidating at first, but once you master the essential commands, it becomes one of your most powerful tools.
You don’t need to memorize all commands at once. Start with the basics (navigation, files, processes) and gradually add more commands to your repertoire.
The Linux terminal is one of the most powerful tools you have. Master it, and you’ll be much more productive as a developer.