Useful Unix / Mac / Docker Commands

See which version of unix we’re on (useful inside a Docker container)

cat /etc/os-release

get approx. size of a dir ( and everything in it)

du -sh [DIRNAME]

eg du -sh ./wherelara/

See what ports are open

sudo lsof -i -P -n | grep LISTEN

Kill all docker containers

docker container kill $(docker ps -q)

Show all files that contain certain text (in their body, not the filename)

grep ‘Math.PI’ ./* -Rl

this searches for the txt ‘Math.PI’ in all files in this directory (and any child directories), print only the filename (and path) on match

-R recursive

-l show filename

Docker show networking information about a running container (eg internal IP address etc)

docker inspect [CONTAINER ID]

e.g.

docker inspect e350390fd549