Boost Linux Admin Productivity 10× with Essential Keyboard Shortcuts & System Tricks
This comprehensive Linux operations guide covers powerful terminal shortcuts, efficient file handling, system monitoring, network diagnostics, process control, performance tuning, and automation scripts, providing practical examples and command references that can dramatically increase an administrator's efficiency.
Introduction
As a Linux operations engineer, mastering these practical shortcuts and system techniques can dramatically improve work efficiency and showcase your skills.
Table of Contents
Terminal Shortcut Mastery
Efficient File Operations
System Monitoring & Diagnosis
Network Management Commands
Process Management & Performance Optimization
Advanced Techniques & Script Automation
Terminal Shortcut Mastery
Cursor Movement (Replace Arrow Keys)
# Cursor quick positioning
Ctrl+A # Jump to line start
Ctrl+E # Jump to line end
Ctrl+F # Move forward one character
Ctrl+B # Move backward one character
Alt+F # Move forward one word
Alt+B # Move backward one word
# Example: Quickly edit a long command
# Original: find /var/log -name "*.log" -type f -exec grep "ERROR" {} \;
# Efficient: Ctrl+A then type sudo at the beginningText Editing (Edit Commands Faster)
# Deletion operations
Ctrl+D # Delete character after cursor
Ctrl+H # Delete character before cursor
Ctrl+K # Delete from cursor to line end
Ctrl+U # Delete from cursor to line start
Ctrl+W # Delete previous word
Alt+D # Delete next word
# Paste and yank
Ctrl+Y # Paste previously deleted text
Alt+Y # Cycle through delete history
# Example: Fix mistyped command
# Mistyped: sudo systemctl restart nginx
# Real command should be apache2
# Efficient: Alt+B to jump to "nginx", Alt+D to delete it, then type apache2History Command Management (Avoid Re‑typing Long Commands)
# History navigation
Ctrl+R # Reverse search history
Ctrl+S # Forward search history
Ctrl+P # Previous command (↑)
Ctrl+N # Next command (↓)
# History shortcuts
!! # Execute previous command
!n # Execute command number n
!string # Execute most recent command starting with string
!?string # Execute most recent command containing string
^old^new # Replace "old" with "new" in previous command and execute
# Example:
$ systemctl status nginx
$ sudo !! # Expands to: sudo systemctl status nginx
$ !sys # Executes most recent command starting with "sys"Efficient File Operations
File Search & Location
# Advanced find usage
# Find log files modified in the last 7 days
find /var/log -name "*.log" -mtime -7 -type f
# Find files larger than 100M and show size
find / -size +100M -type f -exec ls -lh {} \; 2>/dev/null
# Delete empty files
find /tmp -type f -empty -delete
# Find files with 777 permissions (security check)
find /var/www -perm 777 -type f
# Quick locate (faster than find)
updatedb
locate nginx.conf
locate "*.conf" | grep nginxFile Content Processing Tools
# grep advanced search
grep -rn "ERROR" /var/log/
grep -E "(ERROR|WARN|FATAL)" /var/log/syslog
grep -r --exclude="*.tmp" "config" /etc/
grep -A 3 -B 3 "ERROR" /var/log/apache2/error.log
# awk useful tricks
# Count IP accesses in nginx access log
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -nr
# Calculate total file size in current directory
ls -l | awk '{sum+=$5} END {print "Total:", sum/1024/1024 "MB"}'
# sed batch text processing
# Replace port 80 with 8080 in config
sed -i 's/80/8080/g' /etc/nginx/sites-available/default
# Delete empty lines
sed -i '/^$/d' file.txt
# Insert a line before line 10
sed -i '10i\New configuration line' /etc/nginx/nginx.confSystem Monitoring & Diagnosis
Real‑time Monitoring Commands
# htop – enhanced top
htop # F5 tree view, F6 sort, F9 kill, F10 quit
# iostat – disk I/O monitoring
iostat -x 1 # detailed stats every second
iostat -d 2 5 # every 2 seconds, 5 times
# iftop – network traffic monitor
iftop -i eth0
# nload – simple network monitor
nload eth0
# dstat – comprehensive resource monitor
dstat -cdngy # CPU, disk, network, memorySystem Information Collection
# Quick system health check
# CPU info
lscpu
cat /proc/cpuinfo | grep "model name" | head -1
# Memory usage
free -h
cat /proc/meminfo | head -5
# Disk usage analysis
df -h
du -sh /*
du -h --max-depth=1 /var | sort -hr
# Load and uptime
uptime
w # logged‑in users
last | head -10 # recent logins
# Network connections
ss -tuln # listening ports
ss -o state established '( dport = :22 or sport = :22 )' # SSH connectionsNetwork Management Commands
Network Diagnosis Tools
# Connectivity tests
ping -c 4 google.com
traceroute google.com
mtr google.com
# Port testing
telnet 192.168.1.1 22
nc -zv 192.168.1.1 1-1000
# DNS lookup
nslookup google.com
dig google.com
dig @8.8.8.8 google.com
# View network configuration
ip addr show
ip route show
ip link showFirewall Management
# iptables basic operations
iptables -L -n --line-numbers # list rules
iptables -A INPUT -p tcp --dport 80 -j ACCEPT # allow HTTP
iptables -A INPUT -p tcp --dport 443 -j ACCEPT # allow HTTPS
iptables -A INPUT -s 192.168.1.100 -j DROP # block IP
iptables-save > /etc/iptables/rules.v4
# UFW (Ubuntu) simplified firewall
ufw enable
ufw allow 22
ufw allow 80/tcp
ufw deny from 192.168.1.100
ufw status verboseProcess Management & Performance Optimization
Process Control Techniques
# Find processes
pgrep nginx
pgrep -f "python.*django"
# View process tree
pstree -p
ps auxf
# Kill processes
kill PID
kill -9 PID # force kill
killall nginx # by name
pkill -f "python.*django"
# Background job management
nohup long_running_command &
jobs
fg %1 # bring to foreground
bg %1 # send to background
# screen/tmux session management
screen -S session_name # create session
screen -r session_name # reattach
screen -ls # list sessionsPerformance Tuning Techniques
# System tuning parameters
ulimit -a # view limits
cat /proc/sys/fs/file-max # max file descriptors
# Temporarily increase limits
ulimit -n 65536 # increase open files limit
# Permanent limits (edit /etc/security/limits.conf)
* soft nofile 65536
* hard nofile 65536
# Memory management
echo 3 > /proc/sys/vm/drop_caches # clear caches (use with caution)
cat /proc/buddyinfo # view memory fragmentation
# Swap management
swapon -s # list swap
swapoff -a # disable all swap
swapon -a # enable all swapAdvanced Techniques & Script Automation
One‑Click System Information Collection Script
#!/bin/bash
# Quick system health script
echo "=== System Info $(date) ==="
echo "Hostname: $(hostname)"
echo "OS: $(grep PRETTY_NAME /etc/os-release | cut -d'=' -f2)"
echo "Kernel: $(uname -r)"
echo "Uptime: $(uptime)"
echo "=== CPU Info ==="
grep "model name" /proc/cpuinfo | head -1
echo "CPU cores: $(nproc)"
echo "Load: $(cat /proc/loadavg)"
echo "=== Memory ==="
free -h
echo "=== Disk Usage ==="
df -h | grep '^/dev'
echo "=== Network Connections ==="
ss -tuln | grep LISTEN | wc -l && echo "listening ports"
echo "=== Top CPU Consumers ==="
ps aux --sort=-%cpu | head -6Log Monitoring Automation
# Real‑time error log monitoring
#!/bin/bash
# Monitor multiple log files for errors
tail -f /var/log/syslog /var/log/apache2/error.log /var/log/nginx/error.log | \
while read line; do
if echo "$line" | grep -qiE "(error|fatal|critical)"; then
echo "[$(date)] ALERT: $line" | mail -s "Server Error Alert" [email protected]
fi
done
# Log cleanup script
# Compress logs older than 30 days
find /var/log -name "*.log" -mtime +30 -exec gzip {} \;
# Delete compressed logs older than 90 days
find /var/log -name "*.log.gz" -mtime +90 -deleteBatch Server Management
# Use pssh for parallel command execution
# Install: apt install pssh
cat > hosts.txt <<EOF
server1.com
server2.com
server3.com
EOF
# Run a command on all hosts
pssh -i -h hosts.txt "uptime"
# Transfer a file to all hosts
pscp -h hosts.txt /local/file /remote/path/
# Distribute SSH keys
#!/bin/bash
SERVERS="server1 server2 server3"
for server in $SERVERS; do
ssh-copy-id user@$server
echo "Key deployed to $server"
doneBest‑Practice Summary
Golden Principles for Operations
Security First : Perform regular security checks, monitor suspicious logins, audit privileged files, and review network connections.
Backup Is King : Always back up configuration files before changes and regularly dump databases.
Monitoring & Alerts : Set up threshold alerts for disk usage, CPU, memory, and automate email notifications.
Efficiency Habits : Use command aliases, maintain a clean command history, script repetitive tasks, document important operations, and keep learning.
Ops Community
A leading IT operations community where professionals share and grow together.
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.
