惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
F
Full Disclosure
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
G
Google Developers Blog
C
Check Point Blog
GbyAI
GbyAI
A
About on SuperTechFans
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
T
Tor Project blog
AWS News Blog
AWS News Blog
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
aimingoo的专栏
aimingoo的专栏
U
Unit 42
Y
Y Combinator Blog
P
Privacy International News Feed
Cisco Talos Blog
Cisco Talos Blog
S
Securelist
S
Schneier on Security
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
C
Cisco Blogs
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
罗磊的独立博客
Cloudbric
Cloudbric
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog

Stonecharioteer on Tech

I Traced My Traffic Through a Home Tailscale Exit Node What Was I Reading Last? In Three Not-So-Easy Pieces Dogfooding Is Hard Code blocks in your books, finally GoForGo v0.9.0 Merrilin - We built an app to read books I use a Macbook now Data Structures & Algorithms - Preparing for Interviews Using a local DNS namespace for local service discovery Direction KOllector - Publishing KOReader Highlights gbt: branches touched in the last 24 hours A Soiree into Symbols in Ruby Some Smalltalk about Ruby Loops Ruby Blocks Returning from Ruby Blocks, Procs and Lambdas My Linux Laptop Finally Works: How Claude Helped Me Fix Years of Annoyances TIL: Watchexec - Modern File Watching for Development Workflows A Less Busy Mind GoForGo - Learn Go through live examples Migrating My Old Blog to Hugo with Claude The Qtile Window Manager: A Python-Powered Tiling Experience Read the RFCs that Built the Internet Py-x-Protobuf - Or How I Learned to Stop Worrying and Love Protocol Buffers Python Reverse a List New Beginnings Leaving ChainSafe Systems Screen Lock for Cinnamon Desktop using Zenity and Terminal Commands Crews Not Teams A System for Getting Better at LeetCode So Far So Rust Retrying HTTP Requests with Rust A Primer on Control Charts Learning Rust Explicit is Better than Implicit: Rust for Pythonistas Using Custom Delimiters in Jinja Templates TIL: Creating Fixed Length Iterables in Python Documentation Without Assumption Vagrant Python - A Reflection in 2022 Learning Golang No, A Virtual Machine Is Not Enough: Why Developers Need Native Linux Empathy in Tech For Those Who Came in Late A Weekend With PostgreSQL TIL: Gooey and Python Fire for Quick GUIs and CLIs TIL: 2ality - Dr. Axel Rauschmayer's JavaScript Blog TIL: MassDNS - High-Performance Bulk DNS Lookups TIL: Matomo Analytics, Google Tech Writing, Memory Programming, and NES TV Signals TIL: MontyDB - MongoDB Implemented in Python Returning to the Craft of Programming TIL: CPUFetch, OneFetch, and Learn CSS TIL: DNS Performance Testing and Pi-hole with Unbound TIL: Eli Bendersky's Blog, Awesome By Example, NoCoDB, and Martin Kleppmann TIL: CRDTs, Extreme HTTP Performance, and BYTEPATH Game TIL: AutoInvent, ASGI, Python Packaging, RAPIDS GPU Computing, and FlaskCon TIL: MangaDesk - Terminal Client for MangaDex TIL: McFly - Smart Shell History Search TIL: Siege Load Testing and Awesome FastAPI Resources TIL: Ventoy Bootable USB and Justniffer Network Analysis TIL: CLI Code Review, Git Split Diffs, and Internal Combustion Engine TIL: Benford's Law, Web Security Headers, Event Sourcing, and Mozilla Security Guidelines How to Write Documentation - The README.md File The Importance of Documentation TIL: NNgroup UX Research, SponsorBlock, and Labella Python Library TIL: The Little Book of Rust Macros and Rust Performance Book TIL: Git-Bug Distributed Issue Tracker and Omni Kubernetes Monitoring TIL: Zellij - Modern Terminal Multiplexer TIL: How Discord Handles 2.5 Million Concurrent Voice Users TIL: Volumio - The Audiophile Music Player TIL: Areopagitica - Milton's Defense of Free Speech TIL: Fast Node Manager, Zoxide Smart CD, Technical Writing, PyO3, and Qubes OS TIL: Slurm Workload Manager for HPC Clusters TIL: Data Visualization Guide and Oso Authorization Academy TIL: CORS Deep Dive, Piku Tiny PaaS, Rust Strings, and Deno Standard Library TIL: Raspberry Pi OS Development, Vim Beginner Guide, Password Management, and QueryBook TIL: uBlock Origin Performance Optimization on Firefox TIL: Breaking PostgreSQL at Scale and LeetCode Problem Patterns TIL: Awesome Tmux Resources for Terminal Multiplexing TIL: Grit - A Multitree-Based Personal Task Manager TIL: Lens 4.2 Kubernetes IDE, Shell Scripting Guide, and Dark HTTP Server Do The Job You Hate So You Won't Hate The Job You Love TIL: Innernet VPN Solution and NoteCalc Calculator App TIL: Argo CD for GitOps and Lens Kubernetes IDE TIL: Modern Rust CLI Tools - System Monitoring, HTTP Requests, and DNS TIL: tz - A Time Zone Helper Tool TIL: Distributed Systems Education, Fallacies, and Self-Hosted Internet Archiving TIL: Real-Time Voice Cloning Technology TIL: ChartMuseum for Helm, AMD's Corporate Journey, and Kubernetes Pod Scaling TIL: Docker and Kubernetes Tools - Whaler, Descheduler, and Dive TIL: Post-Mortem Collection, Terminal Plotting, and Technical Twitter TIL: Dark Mode Toggle Web Component by Google Chrome Labs TIL: Python eval(), exec(), and compile() Functions TIL: Camelot PDF Tables, PostgreSQL Row Level Security, Zerodha Varsity, and Write Yourself a Git TIL: fuser Command for Process and File Investigation TIL: i Hate Regex - The Ultimate Regex Cheat Sheet TIL: Dolt - Git for Data and Database Version Control TIL: x86 Assembly Programming and SafeEyes Break Reminder TIL: Comprehensive Distributed Systems Reading List TIL: Cosmopolitan C Library, Distributed Systems Book, High Performance Browser Networking, and Rust Roguelike Tutorial
TIL: Advanced Linux System Administration and Monitoring Tools
2020-08-24 · via Stonecharioteer on Tech

Today I explored advanced Linux system administration tools and discovered powerful utilities for monitoring, process management, and productivity enhancement that go far beyond basic system commands.

Advanced Command-Line Utilities

MoreUtils - Extended Linux Commands

MoreUtils provides additional commands that fill gaps in standard Linux utilities:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Essential moreutils commands for system administration

# sponge - soaks up stdin and writes to a file
# Prevents truncation when reading from and writing to the same file
sort file.txt | uniq | sponge file.txt

# vipe - vi pipe editor - edit the pipeline interactively
ps aux | vipe | head -10

# ts - timestamp lines from stdin
tail -f /var/log/syslog | ts '[%Y-%m-%d %H:%M:%S]'

# pee - tee for pipes - duplicate stdin to multiple processes
echo "data" | pee 'wc -c' 'wc -w' 'wc -l'

# parallel - run multiple jobs in parallel
find . -name "*.jpg" | parallel -j4 convert {} {.}.png

# ifdata - query network interface information
ifdata -pN eth0  # Print network statistics for eth0

# isutf8 - check if file is valid UTF-8
isutf8 suspicious_file.txt && echo "Valid UTF-8" || echo "Invalid UTF-8"

# lckdo - run command with file locking
lckdo /tmp/mylock.lock important_singleton_script.sh

# combine - combine sets of lines from files using boolean operations
combine file1.txt and file2.txt    # Intersection
combine file1.txt not file2.txt    # Difference
combine file1.txt or file2.txt     # Union

Practical MoreUtils Applications

Log Processing:

1
2
3
4
5
# Add timestamps to real-time logs
tail -f /var/log/nginx/access.log | ts '%H:%M:%S'

# Edit log filtering pipeline interactively
journalctl -f | grep ERROR | vipe | mail [email protected]

File Operations:

1
2
3
4
5
# Safe in-place editing (no race conditions)
cat config.yml | yq '.database.host = "new-host"' | sponge config.yml

# Parallel file processing
find /data -name "*.csv" | parallel -j8 'gzip {}'

System Monitoring:

1
2
3
4
5
# Network interface monitoring
while true; do ifdata -pN eth0; sleep 1; done

# Process monitoring with timestamps
ps aux | ts | grep postgres

Process Monitoring with PV and Progress

PV (Pipe Viewer) and Progress provide visual feedback for long-running operations:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# PV - Pipe Viewer for monitoring data flow

# Monitor file copy progress
pv /path/to/large_file > /destination/large_file

# Database backup with progress
pg_dump large_database | pv | gzip > backup.sql.gz

# Monitor network transfer
curl -s http://example.com/large_file.zip | pv > large_file.zip

# Limit transfer rate (bandwidth throttling)
pv -L 1M /dev/zero > /dev/null  # Limit to 1MB/s

# Progress with size estimation
pv -s 1G /dev/zero > /dev/null

# Multiple progress bars
pv input1.txt > output1.txt &
pv input2.txt > output2.txt &
wait

# Progress - monitor existing processes
# Install: apt install progress
progress -m  # Monitor all processes with progress info
progress cp  # Monitor specific command
progress -w  # Wide output format

# Advanced PV usage for system administration
# Disk imaging with progress
sudo dd if=/dev/sda | pv -s 500G | dd of=/dev/sdb

# Monitor log file growth
pv /var/log/syslog > /dev/null

# Network throughput testing
pv -L 10M /dev/zero | nc target_host 9999

# File system monitoring
while true; do
    du -sh /var/log | pv -l -s 1 | tail -1
    sleep 60
done

Cheat - Offline Command Reference

cheat provides a community-driven cheatsheet system:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Install and configure cheat
pip install cheat
# or
snap install cheat

# Basic usage
cheat tar        # Show tar command examples
cheat grep       # Show grep examples
cheat ssh        # SSH usage patterns

# List available cheatsheets
cheat -l

# Edit cheatsheets
cheat -e tar     # Edit tar cheatsheet

# Search across all cheatsheets
cheat -s "recursive"

# Create custom cheatsheets
mkdir -p ~/.config/cheat/cheatsheets/personal
cheat -e mycmd   # Create custom cheatsheet

# Example custom cheatsheet content
# ~/.config/cheat/cheatsheets/personal/docker-admin

# Docker container management
docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

# Remove stopped containers
docker container prune -f

# View container resource usage
docker stats --no-stream

# Export/import container filesystem
docker export container_name > container_backup.tar
docker import container_backup.tar new_image:tag

# Container networking
docker network ls
docker network inspect bridge

# Volume management
docker volume ls
docker volume inspect volume_name
docker volume prune

System Resource Monitoring

Advanced Process Management

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Comprehensive process analysis and management

# Process tree with resource usage
ps aux --forest | head -50

# Find processes by resource usage
ps aux --sort=-%mem | head -10  # Top memory users
ps aux --sort=-%cpu | head -10  # Top CPU users

# Process monitoring with specific intervals
watch -n 2 'ps aux --sort=-%mem | head -10'

# Find processes using specific files or directories
lsof /var/log/nginx/
lsof +D /tmp/  # Recursively find processes using /tmp

# Network connections by process
lsof -i :80    # Processes using port 80
lsof -i TCP:LISTEN  # All listening TCP ports
netstat -tulpn | grep :22  # SSH connections

# Process signals and management
# List all available signals
kill -l

# Send specific signals
kill -TERM 1234    # Graceful termination
kill -KILL 1234    # Force kill
kill -STOP 1234    # Suspend process
kill -CONT 1234    # Resume process
kill -USR1 1234    # User-defined signal 1

# Process group management
killall -TERM nginx     # Kill all nginx processes
pkill -f "python script.py"  # Kill by command pattern

# Advanced process monitoring script
#!/bin/bash
monitor_processes() {
    echo "=== System Resource Monitor ==="
    echo "Date: $(date)"
    echo

    echo "=== Load Average ==="
    uptime
    echo

    echo "=== Memory Usage ==="
    free -h
    echo

    echo "=== Top CPU Processes ==="
    ps aux --sort=-%cpu | head -6
    echo

    echo "=== Top Memory Processes ==="
    ps aux --sort=-%mem | head -6
    echo

    echo "=== Disk Usage ==="
    df -h | grep -v tmpfs | head -10
    echo

    echo "=== Network Connections ==="
    ss -tuln | head -10
    echo
}

# Run monitoring
monitor_processes

System Performance Analysis

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Comprehensive system performance monitoring

# I/O statistics
iostat -x 1 5    # Extended I/O stats every second, 5 times
iotop -o        # Show only processes with I/O activity

# Network statistics
iftop           # Real-time network bandwidth by connection
nethogs         # Network usage by process
ss -i           # Socket statistics with details

# Memory analysis
vmstat 1 5      # Virtual memory statistics
slabtop         # Kernel slab allocator information
cat /proc/meminfo | grep -E "(MemTotal|MemFree|Cached|Buffers)"

# CPU analysis
mpstat 1 5      # Multi-processor statistics
pidstat -u 1 5  # Per-process CPU usage
cat /proc/loadavg  # Current load average

# Advanced system monitoring script
#!/bin/bash
comprehensive_monitor() {
    local duration=${1:-300}  # Default 5 minutes
    local interval=${2:-5}    # Default 5 seconds
    local logdir="/var/log/system-monitor"

    mkdir -p "$logdir"
    local timestamp=$(date +%Y%m%d_%H%M%S)
    local logfile="$logdir/monitor_$timestamp.log"

    echo "Starting comprehensive system monitoring..."
    echo "Duration: ${duration}s, Interval: ${interval}s"
    echo "Log file: $logfile"

    # System info header
    {
        echo "=== System Monitor Report ==="
        echo "Start time: $(date)"
        echo "Hostname: $(hostname)"
        echo "Kernel: $(uname -r)"
        echo "Uptime: $(uptime)"
        echo
    } > "$logfile"

    # Monitoring loop
    local iterations=$((duration / interval))
    for ((i=1; i<=iterations; i++)); do
        {
            echo "=== Sample $i/$(iterations) at $(date) ==="

            # CPU usage
            echo "--- CPU ---"
            mpstat | tail -1

            # Memory usage
            echo "--- Memory ---"
            free -m | grep -E "(Mem|Swap)"

            # Load average
            echo "--- Load ---"
            cat /proc/loadavg

            # Top processes
            echo "--- Top CPU Processes ---"
            ps aux --sort=-%cpu | head -6 | tail -5

            echo "--- Top Memory Processes ---"
            ps aux --sort=-%mem | head -6 | tail -5

            # Disk I/O
            echo "--- Disk I/O ---"
            iostat -x | grep -E "(Device|[s|h|n]d[a-z])" | tail -5

            # Network
            echo "--- Network ---"
            cat /proc/net/dev | grep -E "(eth|ens|enp)" | head -3

            echo "----------------------------------------"
            echo
        } >> "$logfile"

        sleep "$interval"
    done

    echo "Monitoring complete. Report saved to: $logfile"
}

# Usage: comprehensive_monitor [duration_seconds] [interval_seconds]
# comprehensive_monitor 600 10  # Monitor for 10 minutes, sample every 10 seconds

Security and Process Control

Chesterton’s Fence Principle

Chesterton’s Fence - understanding why systems exist before changing them:

System Administration Wisdom

Chesterton’s Fence Applied to System Administration:

“Do not remove a fence until you know why it was put up.”

Practical Applications:

  • Configuration files - Understand why settings exist before changing them
  • Running processes - Research process purpose before killing it
  • Firewall rules - Understand rule purpose before removal
  • Cron jobs - Investigate job history before deletion
  • User permissions - Understand access patterns before modification

Safe Investigation Process:

  1. Document current state
  2. Research configuration history (git logs, documentation)
  3. Test changes in staging environment
  4. Implement changes gradually with rollback plan
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Safe system administration practices

# Document system state before changes
document_system_state() {
    local backup_dir="/var/backups/system-state/$(date +%Y%m%d_%H%M%S)"
    mkdir -p "$backup_dir"

    # Configuration backups
    cp -r /etc "$backup_dir/etc_backup"

    # Process list
    ps aux > "$backup_dir/processes.txt"

    # Network configuration
    ip addr show > "$backup_dir/network_config.txt"
    ss -tuln > "$backup_dir/listening_ports.txt"

    # Installed packages
    dpkg -l > "$backup_dir/installed_packages.txt"

    # System services
    systemctl list-units --type=service > "$backup_dir/services.txt"

    # Disk usage
    df -h > "$backup_dir/disk_usage.txt"

    echo "System state documented in: $backup_dir"
}

# Investigate before modification
investigate_process() {
    local pid=$1

    if [[ -z "$pid" ]]; then
        echo "Usage: investigate_process <PID>"
        return 1
    fi

    echo "=== Process Investigation: PID $pid ==="

    # Basic process info
    ps -p "$pid" -o pid,ppid,user,start,command

    # Process tree
    pstree -p "$pid"

    # Open files
    echo "--- Open Files ---"
    lsof -p "$pid" | head -10

    # Network connections
    echo "--- Network Connections ---"
    lsof -i -p "$pid"

    # Memory maps
    echo "--- Memory Usage ---"
    pmap -d "$pid" | tail -1

    # System calls (if strace available)
    if command -v strace >/dev/null; then
        echo "--- Recent System Calls (5 second sample) ---"
        timeout 5 strace -p "$pid" -c 2>&1 | tail -10
    fi
}

# Safe configuration editing
safe_config_edit() {
    local config_file=$1

    if [[ -z "$config_file" ]]; then
        echo "Usage: safe_config_edit <config_file>"
        return 1
    fi

    if [[ ! -f "$config_file" ]]; then
        echo "Error: File does not exist: $config_file"
        return 1
    fi

    # Create backup
    local backup_file="${config_file}.backup.$(date +%Y%m%d_%H%M%S)"
    cp "$config_file" "$backup_file"
    echo "Backup created: $backup_file"

    # Test configuration if possible
    case "$config_file" in
        */nginx/*)
            if command -v nginx >/dev/null; then
                echo "Testing nginx configuration..."
                nginx -t
            fi
            ;;
        */apache*/*)
            if command -v apache2ctl >/dev/null; then
                echo "Testing apache configuration..."
                apache2ctl configtest
            fi
            ;;
        */ssh/sshd_config)
            echo "Testing SSH configuration..."
            sshd -t
            ;;
    esac

    # Edit the file
    ${EDITOR:-nano} "$config_file"

    # Offer to restore backup
    echo "Configuration edited. Restore backup? (y/N)"
    read -r response
    if [[ "$response" =~ ^[Yy]$ ]]; then
        cp "$backup_file" "$config_file"
        echo "Configuration restored from backup"
    fi
}

Mnemonic - CLI Memory Aid

Mnemonic helps remember complex commands:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Install mnemonic
cargo install mnemonic

# Basic usage
mnemonic add "complex-docker-cmd" "docker run -it --rm -v \$(pwd):/workspace ubuntu:latest bash"

# Use saved command
mnemonic run complex-docker-cmd

# List all mnemonics
mnemonic list

# Search mnemonics
mnemonic search docker

# Edit existing mnemonic
mnemonic edit complex-docker-cmd

# Advanced usage with variables
mnemonic add "deploy-service" "docker build -t \$1 . && docker push \$1 && kubectl set image deployment/\$2 \$2=\$1"

# Use with parameters
mnemonic run deploy-service myapp:v1.2.3 web-service

System Administration Shortcuts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Create a comprehensive system admin toolkit
# ~/.bashrc or ~/.zshrc additions

# Quick system status
alias systat='echo "=== System Status ===" && uptime && echo "=== Memory ===" && free -h && echo "=== Disk ===" && df -h | head -10'

# Process management shortcuts
alias topcpu='ps aux --sort=-%cpu | head -10'
alias topmem='ps aux --sort=-%mem | head -10'
alias ports='ss -tuln'

# Log monitoring
alias syslog='tail -f /var/log/syslog'
alias authlog='tail -f /var/log/auth.log'
alias nginxlog='tail -f /var/log/nginx/error.log'

# Service management
alias services='systemctl list-units --type=service --state=running'
alias failed='systemctl list-units --type=service --state=failed'

# Network utilities
alias myip='curl -s ipinfo.io/ip'
alias netstat='ss -tuln'
alias listen='ss -tuln | grep LISTEN'

# File operations
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Safety aliases
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Advanced functions
monitor_service() {
    local service=$1
    if [[ -z "$service" ]]; then
        echo "Usage: monitor_service <service_name>"
        return 1
    fi

    watch -n 2 "systemctl status $service"
}

find_large_files() {
    local size=${1:-100M}
    local path=${2:-.}
    find "$path" -type f -size +"$size" -exec ls -lh {} + | sort -k5 -hr
}

check_service_logs() {
    local service=$1
    local lines=${2:-50}

    if [[ -z "$service" ]]; then
        echo "Usage: check_service_logs <service_name> [lines]"
        return 1
    fi

    journalctl -u "$service" -n "$lines" --no-pager
}

Key System Administration Insights

Effective Monitoring Strategies

System Monitoring Best Practices

Proactive Monitoring:

  1. Baseline Establishment - Know normal system behavior
  2. Threshold Setting - Define alert thresholds based on baselines
  3. Log Aggregation - Centralize logs for correlation analysis
  4. Automated Responses - Script common remediation tasks
  5. Documentation - Maintain runbooks for common issues

Essential Metrics:

  • CPU usage and load averages
  • Memory utilization and swap usage
  • Disk I/O and space utilization
  • Network throughput and connection counts
  • Process states and resource consumption

Command-Line Productivity Principles

Productivity Multipliers

Tool Selection:

  • Specialized tools over general-purpose commands (htop vs top)
  • Interactive tools for exploration (iotop, iftop)
  • Scriptable tools for automation (jq, awk, sed)
  • Visual tools for complex data (pv, progress)

Workflow Optimization:

  • Aliases for frequently used commands
  • Functions for complex operations
  • History management and search
  • Tab completion for efficiency
  • Screen/tmux for session management

This exploration of advanced Linux system administration tools demonstrates that effective system management requires both deep tool knowledge and systematic approaches to monitoring, troubleshooting, and maintenance.


These Linux system administration insights from my archive showcase the evolution from basic command usage to sophisticated system management practices, emphasizing the importance of understanding system behavior and implementing proactive monitoring strategies.