🔥 Trending This Week
1. rsync Edge Cases: Handling 10M+ files with --link-dest
When synchronizing massive directories, --link-dest is crucial for speed and storage efficiency by creating hard links to unchanged files.
# Create an incremental backup using hard links
rsync -aH --delete --link-dest=/path/to/previous_backup/ \
/source/ /destination/$(date +%Y%m%d)/
2. journalctl Mastery: Filtering kernel logs like an SRE
Isolate specific kernel errors from the last boot with precise time and priority filtering.
# Show kernel errors from the last boot with exact timestamps
journalctl -k -b -0 --no-pager -o short-iso \
-p err --since "2023-05-01 14:00:00"
3. Bash Process Substitution: <() vs >()
Compare sorted files on the fly without creating temporary files on disk.
# Compare two sorted files without temp files
diff <(sort file1) <(sort file2)
Shell Fu - Advanced Techniques
Signal Handling Deep Dive
Create robust scripts that clean up resources reliably, even when interrupted.
# Comprehensive signal management in a script
trap '{
echo "Cleaning tempdir $TEMPDIR";
rm -rf "$TEMPDIR";
[[ -n "$SUBPROCESS" ]] && kill "$SUBPROCESS";
exit 1;
}' EXIT INT TERM HUP
Parameter Expansion Mastery
Perform advanced string manipulation directly in the shell without external tools like `sed` or `awk`.
filename="backup.tar.gz"
# Remove shortest suffix (*.gz)
echo ${filename%.*} # backup.tar
# Remove longest suffix (*.tar.gz)
echo ${filename%%.*} # backup
Professional Toolchest
jq for JSON
Safely extract nested values from a JSON object, providing a default if the key doesn't exist.
# Extract nested values with null safety
jq '.user?.contacts?.email // "none"' data.json
tmux Workflows
Manage persistent sessions for long-running tasks.
# Create a detached session named 'work'
tmux new -s work -d
# Send commands to the session
tmux send-keys -t work 'vim ~/project' Enter
⚠️ Danger Zone: Caution Advised
These commands can cause irreversible data loss or system instability. Use with extreme care and preferably in a non-production environment.
# Filesystem Wipe (no confirmation!)
dd if=/dev/zero of=/dev/sda bs=4M
# Forcibly trigger a kernel panic
echo c > /proc/sysrq-trigger