Linux Shell Toolkit
Essential Unix commands: file ops, text processing, process mgmt, networking.
linuxshellbash
# Linux Shell Toolkit
## Files
- `ls -lah` -- list with sizes
- `find . -name '*.log' -mtime -7` -- modified within 7 days
- `du -sh *` / `df -h` -- disk usage
- `tree -L 2`
- `stat file` -- detailed info
## Text processing
- `grep -rni 'pattern' .` -- recursive, line numbers, ignore case
- `rg pattern` -- ripgrep, faster
- `sed -i 's/foo/bar/g' file` -- in-place replace
- `awk '{print $1, $3}' file` -- column extract
- `sort | uniq -c | sort -rn` -- frequency count
- `cut -d',' -f1,3 file.csv`
- `jq '.users[].name' data.json`
## Pipes & redirection
- `cmd1 | cmd2` -- pipe stdout
- `cmd > file` overwrite, `cmd >> file` append
- `cmd 2>&1` redirect stderr to stdout
- `cmd 2>/dev/null` discard errors
- `< file cmd` -- feed file as stdin
## Processes
- `ps aux | grep node`
- `top` / `htop`
- `kill -9 PID` / `pkill -f node`
- `nohup cmd &` -- run detached
- `jobs`, `fg %1`, `bg %1`
## Networking
- `curl -sS https://x` / `curl -X POST -d @body.json -H 'Content-Type: application/json' url`
- `wget url`
- `ss -tlnp` -- listening sockets (replaces netstat)
- `ping host`, `dig host`, `nslookup host`
## SSH
- `ssh user@host`
- `scp file user@host:/path`
- `rsync -avz src/ user@host:/dst/`
- Forward: `ssh -L 8080:localhost:80 user@host`
## Permissions
- `chmod 755 file` (rwx r-x r-x)
- `chown user:group file`
- Find SUID files: `find / -perm -4000 2>/dev/null`
API: /api/skills/linux-shell