Print every environment variable in alphabetical order — handy when debugging missing config or checking what a script will see.
$ printenv | sort
# Or just search for a specific one:
printenv | grep -i path
Delete this trick? This cannot be undone.
Cancel
Forgot to sudo? Run the previous command with root privileges without re-typing it.
Delete this trick? This cannot be undone.
Yes, delete
Cancel
Before editing a config, make a dated backup with a one-liner. The $(date) sub-shell appends the current timestamp.
$ cp nginx.conf nginx.conf.$(date +%Y%m%d_%H%M%S).bak
# Backup and keep last 5 only:
cp important.conf important.conf.$(date +%Y%m%d).bak
ls -t important.conf.*.bak | tail -n +6 | xargs rm -f
Delete this trick? This cannot be undone.
Yes, delete
Cancel
Serve the current directory over HTTP for quick file sharing on the LAN — requires only Python 3.
$ python3 -m http.server 8080
# On a specific interface:
python3 -m http.server 8080 --bind 0.0.0.0
# Then access from another machine:
curl http://<your-ip>:8080/
Delete this trick? This cannot be undone.
Yes, delete
Cancel
A universal extract function you can add to ~/.bashrc — handles tar.gz, zip, bz2, 7z and more.
$ extract() {
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.xz) tar xJf "$1" ;;
*.zip) unzip "$1" ;;
*.7z) 7z x "$1" ;;
*.gz) gunzip "$1" ;;
*) echo "Unknown format: $1" ;;
esac
}
# Usage:
extract archive.tar.gz
Delete this trick? This cannot be undone.
Yes, delete
Cancel