colaianni.us

Ball Knowledge

Tidbits of knowledge I’ve picked up over the years using Linux.

  1. In most Linux terminals, pressing Ctrl+d sends an EOF key
  2. tail +X means start printing at line X
  3. In bash
    1. !! repeats the previous command
    2. !$ reuses the last command’s last arguments
    3. !* reuses all arguments from the last command
  4. Bash can match directories recursively with **, as long as globstar is enabled: shopt -s globstar
  5. find -exec ... {} + batches files efficiently rather than launching a new process for each
  6. fold is like cat but wraps text
  7. lsof tells you who’s using a file
  8. Shell variables can remove text w/ pattern syntax
    1. ${var#pattern} removes the shortest match from the front
    2. ${var##pattern} removes the longest match from the front
    3. ${var%pattern} removes the shortest match from the back
    4. ${var%%pattern} removes the longest match from the back
  9. ps -o etime= -p "$pid" to show how long a process has been running
  10. ss -natp shows all active connections
  11. Network manager can automatically activate a VPN
    1. nmcli connection modify <connection> connection.secondaries <secondary-uuid>
  12. Network manager can display a Wi-Fi password & show a QR code
    1. nmcli device wifi show-password
  13. You can use ffmpeg and nc to stream a webcam over network
    1. ffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -preset ultrafast -f matroska - | ncat -lp 5050 on the host
    2. ncat host 5050 | mpv - on the receiving machine
  14. Quickly inspect a docker container: docker run --rm -it -v volume_name:/mnt debian:latest bash
  15. docker history --no-trunc image-name shows what layers are contributing to an image’s size
  16. Vim can transfer an entire buffer though another program (send open file to a program): :%!jq
  17. PostgreSQL can clone databases: CREATE DATABASE new_db WITH TEMPLATE old_db;
  18. PostgreSQL search_path changes the default schema: SET search_path = "my_schema";
  19. sshuttle is a VPN over ssh
  20. People can share a tmux session tmux -S /tmp/shared new -s session
  21. qpdf is a beautiful program made by beautiful people
    1. Extract pages: qpdf input.pdf --pages . 3-7 -- output.pdf
    2. Combine pages: qpdf first.pdf --pages . second.pdf 1-4 -- combined.pdf
Previous:
An AWS Deployment Setup I Actually Like