How to do various things

General *nix

Run sed on every Rust source file in a directory (GNU):

find . -type f -name '*.rs' -exec sed -i 's/\(DataflowDesc::new(\)None/\1/' {} \;

Above for BSD:

find . -type f -name '*.rs' -exec sed -i '' 's/\(DataflowDesc::new(\)None/\1/' {} \;

Convert a Unix timestamp to a local date/time (GNU):

date -d @1571862547

Above for BSD:

date -r 1571862547

Get number of CPUs (BSD):

sysctl hw.ncpu

Get all the nodes watched in an inotify instance (GNU/Linux):

for f in $(cat fdinfo/6 | perl -ne 'if (/ino:([0-9a-f]*)/) { print hex $1 ; print "\n" }'); do
sudo debugfs -R "ncheck $f" /dev/nvme0n1p1 2>/dev/null | awk 'BEGIN {d=1} {d=!d; if (d) {print $0}}'
done

Arch

Check what package owns a file:

pacman -Qo `which tail`

Checkout the source for a a package:

asp checkout coreutils

Ubuntu

Find files associated with a given package:

dpkg-query -L <package>

FreeBSD server admin

Renew LetsEncrypt certificate:

certbot-3.6 renew
service dovecot onerestart
service nginx onerestart
# And whatever else you might need to restart...

Install patches:

freebsd-update fetch
freebsd-update install

Docker

Blow away a bunch of stuff (caches, unused volumes, etc):

docker system prune -a && docker volume prune

Default Ports

Service Port
Confluent Schema Registry 8081
Zookeeper 2181
Kafka 9092
SMTP 25
SMTPS 465
SMTP submission 587
IMAP 143
IMAPS 993
Confluent Control Center 9021

Miscellaneous

Render Graphviz graph:

dot -T pdf < graph.dot > graph.pdf

Render this file:

rst2html < howtodo.rst > howtodo.html