Terminal cheat sheet
The bash and zsh one-liners you search for every few weeks: what’s eating the disk, what’s on port 3000, find that file, count those lines.
In Snippet Keeper, click Import at the bottom of the sidebar and choose the file. They land in your terminal app, and ones you already have are skipped. The highlighted parts become fill-in fields: type a value (or pick one), and the finished command is on your clipboard.
Files
find dir -name "pattern"
find dir -type f -size +size
du -sh dir/* | sort -h
df -h
grep -rn "text" dir
perl -pi -e 's/find/replace/g' files
tail -f file
tar -czf name.tar.gz dir
tar -xzf file
chmod +x file
ln -s target link
Processes and ports
lsof -i :port
kill $(lsof -t -i :port)
ps aux | grep -i name
pkill -f name
nohup command > log 2>&1 &
time command
watch -n seconds command
Network
dig +short domain
nc -zv host port
curl -s https://ifconfig.me
Text
sort file | uniq -c | sort -rn | head -count
awk '{print $column}' file
jq . file
printf '%s' 'text' | base64
printf '%s' 'text' | base64 --decode
openssl rand -base64 bytes
shasum -a 256 file
Shell
Ctrl-R
sudo !!
cd -
export PATH="dir:$PATH"
source ~/.file
Mac only
command | pbcopy
open dir
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
caffeinate -d
Keep these one keystroke away.
Snippet Keeper is a Mac app for the commands you keep looking up. Press ⌥⇧Space in any app, type a few letters, fill in the blanks, and it’s on your clipboard.