adam.nz aboutpostsprojectscontact
A man casting a shadow over a wall covered in project nerdy text.

When I was learning Unix in the early nineties I struggled to understand and remember the syntax of commandline tools. To help myself learn, each time I discovered a new command, I’d record each new success so I had a known good starting point for the next time.

Initially I kept these notes in ~/etc/ so they were easy to grep. Later they moved to a wiki page where they continued to flourish, and then finally to my WordPress site where they languished … until (hopefully) now!

Over the years I've kept the habit because it continues to be useful.

101 Recently Updated Gists

blah
(panther) Revert focus follow mouse back to normal off setting by deleting the change.
On every host defined in the Ansible inventory file, append foo.rsync.net’s SSH host key to root’s known_hosts file.
Mailman page to modify individual subscriptions
Change password for user adam from the commandline on a Dockerised NextCloud installation.
Case-insensitive searching with gawk by setting builtin variable.
List all local snapshots and then delete them.
List Homebrew packages which were installed manually (as opposed to pulled in as a dependency of something else).
Show all files attached to PID 2345 (-R means include ppid info).
Disable X11 starting on boot with GDM3 / systemd. Use get-default to read current setting. To restore X11 use graphical.target.
To get better font rendering on Linux, disable hinting and subpixel rendering, and enable stem darkening by adding this to your /etc/environment file.
Redirect stderr to stdout
sets up stunnel to map ssl traffic coming into 995 to the local pop port unencrypted.
tells all about the package.
Blah
Start up OpenLDAP pointing explicitly to the config file and setting debugging to my preferred setting.
Upgrade Debian
Checks (but does not retrieve or delete) messages for larry@alaska.net (-k keeps on server)
Dumps the structure and the data of all databases to mysql_all.sql (including all the MySql specific create commands)
Create thumbnail page with four images per column, omitting image count in caption, using captions and creating “web sized” images for display in slide page.
Resends mail.
shows which ntp servers you are connected to
How to watch POP3 or IMAP4 traffic going to 192.168.1.1
Gives you NSblahblah-HST (can use IP# too)
Use awk to generate a list of usernames from a CSV list of full names by grepping the passwd file.
Show all grants for the user iaddressbook on the host localhost.
Generate a list of all 1Password groups and the vaults which they are mapped to.
How to only grep stderr without redirecting all of stderr to stdout. Can use “| tee 2> >(grep …)” on a command which doesn’t support redirection.
Recursively compare two folders and see differences in a format useful to humans.
Case-insensitive searching with awk by forcing $0 to lowercase.
Shows harrdware information on the primary disk.
Generate SSHFP DNS entries for a host remotely.  See also sshfp2cf for automatically creating SSHFP records on Cloudflare.
Stuff
LILO: To get to root without the root password
Submit DNS queries and get JSON answer back.
New tool built into macOS 12 (Monterey) to test quality of internet connection (some details at danpetrov.xyz). #speedtest
How to SSH to a Cisco switch which only supports old key exchange algorithms. The error you get without is: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
Update UFW firewall to allow all TCP traffic to ports 80, 443 and 8080-8090 inclusive and adds a comment for the rule.
As the user www-data run the command php console.php files:scan –all on the container “nextcloud-app”.
Broadcast a DHCP client request with a MAC address and see responses from all DHCP servers.
Prints hardware info
Turn on a systemd service at book (I think, need to read systemd docs …).
Build a composite docker compose file by overlaying volumes-cached.yml over the top of docker-compose.yml.
How to look up the IP address on a Linux host which doesn’t have any binaries to look it up for you (eg. a minimal docker host without ifconfig or ip).
Download the file and keep the file if the transfer gets interrupted allowing it to be resumed where it left off.
Will work with any ip not just networks
Removes all ^M from DOS file
Gather facts from all configured hosts (replace all with a hostname to run against a single host).
Recursively copy the contents of WorkPace.app and the resource forks into a compressed CPIO archive.
Fix slow performance of macOS addressbook/contacts app. Only works for contacts stored locally, for CardDAV clients just remove contacts via System Settings > Internet Accounts (source).
Truss pid PID and follows forks (good for daemons)
Sort of line Linux strace only in a top form and not really the same. Shows information about PID 1234
Python tool (domainaware/checkdmarc)for looking up DMARC and SPF record and showing any warnings.
Grep my IkiWiki blog for any line beginning with [[!tag and strip off the formatting and print out one tag per line.
Add to `.zshrc` to automatically start a tmux session on login.  If there is an existing session, it will attach, otherwise it'll spawn a new tmux session.
The same as newaliases
eg. if you manually build Apache and then want to install a Debian package which requires Apache
Load a CSV into an in memory SQLite database and then do a SQL query on the data (details).
List all APFS snapshots on local disk; delete a snapshot to free up space and mount a snapshot to recover files.
Bootstrap Chezmoi in new ${HOME}.  Download binary, install dotfiles from Github user adamshand using SSH authentication, and then delete downloaded binary.
Take a screenshot of a website (details).
Add to your ~/.zshrc and then you can search these gists from the shell with: gists <keyword>
Transparently SSH to a second box via a first one. Very useful for opening a shell on a host which isn’t reachable from your current network.
Editor roulette, via /u/zebediah49/
Use the BitWarden commandline to retrive an item and then jq to only print the password. More information at ryan.himmelwright.net.
same as the host version
Renames all files listed to YYYY-MM-DD_HH-MM-SS (where date is when the picture was taken via EXIF data).
If you can’t use ssh-copy-id to upload your ssh key to a remote host you might be able to use this.
Disable .DS_Store and AppleDouble files on network and USB devices.
Prints the date 7 days from now in unix time (could also do –date “7 days ago”).
4 pg/pg to printer vger
Show what package /usr/local/sbin/mtr belongs to.
Run ansible-playbook with gateway.spack.org as an SSH jump host.
Reset the MBR (master boot record). This doesn’t clear the MBR it restores it to a factory default (or something like that??).
Two different ways to use awk to print the entire line except the first field.  The first option is simpler but leaves a leading space.
Copy ssh key to leia via the jump host gateway.
Test NFS locking semantics.
remove control characters from man output
Create a RAM disk (tmpfs) with a maximum size of 50MB and read/write only by root (default is mode 1777). See /usr/src
Download an archiveable copy of a website using wget.
Resizes a directory full of images to thumbnail size suitable for incorporating into a “life poster” (see comment by Mark Pilgrim).
Use the time command to see how long a process takes to run. Output is formatted by the TIME variable (long format elapsed time). Details here.
Prints date thirty minutes ago
Search the entire drive for files called core or dead.letter which are older then 7 days and delete them.
Print the list of dates between 2010-01-01 and 2010-01-10 skipping weekends. Just part of the amazing dateutils package.
Tweak rclone to use as little memory as possible.
Shows package info
IPTables deny
Provide ssh password on commandline so you script commands like rsync.
Connect to smtp.spack.org:587 and initiate an SMTP STARTTLS session. More OpenSSL examples here.
installs onto the /mnt mounted device using etc/lilo.conf as the source file.
Run a shell command as root on all servers in the webservers group.
View Caprover logs
Takes standard in (from echo in this case) and replaces all instances of foo with BAZ.
Provides a top-like view of network traffic. Shows only TCP traffic on WiFi interfaces from processes named java or httpd.
How to simulate bash commandline arguments.
Will delete all packages which have only been partially removed (eg. removed but not purged). Replace purge with search to get a list of partially removed packages.
Add to your websites /robots.txt to disable OpenAI's GPT bot from scraping your site.
Tries to run things without the binary modules which will allow to to repair really broken stuff.
Forward all traffic, including DNS, over an ssh tunnel.
CPU is a LDAP aware clone of the user/add/mod/del commands, -w means prompt for the password on the command line and the rest of the arguments are very similar to user* tools. The majority of the config can go into /etc/cpu.conf