Ball Knowledge
Tidbits of knowledge I’ve picked up over the years using Linux.
- In most Linux terminals, pressing Ctrl+d sends an
EOFkey tail +Xmeans start printing at line X- In bash
!!repeats the previous command!$reuses the last command’s last arguments!*reuses all arguments from the last command
- Bash can match directories recursively with
**, as long as globstar is enabled:shopt -s globstar find -exec ... {} +batches files efficiently rather than launching a new process for eachfoldis like cat but wraps textlsoftells you who’s using a file- Shell variables can remove text w/ pattern syntax
${var#pattern}removes the shortest match from the front${var##pattern}removes the longest match from the front${var%pattern}removes the shortest match from the back${var%%pattern}removes the longest match from the back
ps -o etime= -p "$pid"to show how long a process has been runningss -natpshows all active connections- Network manager can automatically activate a VPN
nmcli connection modify <connection> connection.secondaries <secondary-uuid>
- Network manager can display a Wi-Fi password & show a QR code
nmcli device wifi show-password
- You can use
ffmpegandncto stream a webcam over networkffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -preset ultrafast -f matroska - | ncat -lp 5050on the hostncat host 5050 | mpv -on the receiving machine
- Quickly inspect a docker container:
docker run --rm -it -v volume_name:/mnt debian:latest bash docker history --no-trunc image-nameshows what layers are contributing to an image’s size- Vim can transfer an entire buffer though another program (send open file to a program):
:%!jq - PostgreSQL can clone databases:
CREATE DATABASE new_db WITH TEMPLATE old_db; - PostgreSQL
search_pathchanges the default schema:SET search_path = "my_schema"; - sshuttle is a VPN over ssh
- People can share a tmux session
tmux -S /tmp/shared new -s session - qpdf is a beautiful program made by beautiful people
- Extract pages:
qpdf input.pdf --pages . 3-7 -- output.pdf - Combine pages:
qpdf first.pdf --pages . second.pdf 1-4 -- combined.pdf
- Extract pages: