Commands I Always Need to Google
Just a running list of commands I forget constantly. Mostly Linux stuff, occasionally other junk. No commentary, no fluff—just copy/paste when your brain blanks.
Run a quick python server:
python3 -m http.server
Find and sort files in a dirname based on their modification times
find dirname -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head
Exchange SSH keys with a server
ssh-copy-id remote_user@host
Directory Operations
# Get directory size
du -sh /path/to/directory
# Sort files and directories by size
du -sh -- * | sort -rh
# Just sort directories by size
du -sh -- */ | sort -rh
# Just the top 10 of either
du -sh -- */ | sort -rh | head -n 10
Compress a file or directory
tar -czf new-file.tar.gz oldfile oldirectory
Extract a compressed tar.gz
tar -xzf filename.tar.gz
Create backup with exclusions
tar -cvpf /backups/fullbackup.tar --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=foo --exclude=mnt .
Allow PPA metadata changes when updating Ubuntu
# Ensure Ubuntu is >= 18.04 LTS, or apt version is >= 1.6
sudo apt-get update --allow-releaseinfo-change
yt-dlp
Use cookies (from file)
yt-dlp --cookies cookies.txt --user-agent "agent string" downloadurl
Default Best Video + Audio
yt-dlp -f "bv*+ba/b" "URL"
Force a Specific Format
yt-dlp -f "bv*+ba/b" -S "ext:mp4:m4a" --recode mp4 "URL"