TIPS , LINUX

bash Tips

#bash

Command Tips

String the watch command with several commands at once

watch 'command | othertool | yet-another-tool'

This one is useful when you don’t have a user directory on the system yet.

/sbin/mkhomedir_helper <username> [<umask> [<skeldir>]]

Because docker rmi on all image IDs doesn’t work when one image ID maps to multiple repo:tag combinations.

$ docker images | grep -v REPO | awk '{print $1":"$2}' | xargs docker rmi

Otherise this works fine:

$ docker images -q | xargs docker rmi

Or

$ docker rmi $(docker images -a -q)

Remove exited containers:

$ docker rm $(docker ps -a -f status=exited -q)
$ docker system prune -a

JQ with a dot in the key name:

$ cat router-certs-default.json | jq .data[\"tls.crt\"] -r | base64 -d | openssl x509 -in - -text -noout

Test a port with a telnet connection (useful if you don’t have netcat or telnet)

$ curl -v telnet://<ServerIP>:Port