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
Set awk field delimiter to use a character class (be either <space> or <period>).
tells all about the package.
Same as above only bind as
uid=adam
and prompt for the password (-w <password>
to specify on the command line)Disable’s linux screen saver
(panther) Revert focus follow mouse back to normal off setting by deleting the change.
Connect to
smtp.spack.org:587
and initiate an SMTP STARTTLS session. More OpenSSL examples here.Flushes the local DNS cache (useful if you’ve changed mail server IP addresses or something)
The
-t 10
is just in case a user is actually logged in to the test system, not that 10 seconds gives them much time to do anything but freak out. The -c
is just so they ask me what an “id10t system error” is.To get better font rendering on Linux, disable hinting and subpixel rendering, and enable stem darkening by adding this to your
/etc/environment
file.sets up stunnel to map ssl traffic coming into 995 to the local pop port unencrypted.
Blah
create and mount a ramdisk
/etc/apt/apt.conf
line for apt through a proxy.Generate a list of all 1Password groups and the vaults which they are mapped to.
Print headers and contents of whoami.spack.org to standard out, but follow and show any redirects.
Reset the MBR (master boot record). This doesn’t clear the MBR it restores it to a factory default (or something like that??).
Disable
.DS_Store
and AppleDouble files on network and USB devices.Copy ssh key to leia via the jump host gateway.
How to break out parts of an absolute file path in Bash.
Delete cached files in
~/Library/Caches/Homebrew/
Tweak rclone to use as little memory as possible.
Provides a top-like view of network traffic. Shows only TCP traffic on WiFi interfaces from processes named
java
or httpd
.On every host defined in the Ansible inventory file, append foo.rsync.net’s SSH host key to root’s known_hosts file.
Download an archiveable copy of a website using
wget
.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
Remove all files which aren't managed by Git.
Bring up a wireless wpa2 network from the command line.
Print the list of dates between
2010-01-01
and 2010-01-10
skipping weekends. Just part of the amazing dateutils package.Takes standard in (from
echo
in this case) and replaces all instances of foo
with BAZ
.Use the BitWarden commandline to retrive an item and then
jq
to only print the password. More information at ryan.himmelwright.net.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.
Resizes a directory full of images to thumbnail size suitable for incorporating into a “life poster” (see comment by Mark Pilgrim).
Submit DNS queries and get JSON answer back.
List Homebrew packages which were installed manually (as opposed to pulled in as a dependency of something else).
same as the host version
Prints date thirty minutes ago
Zip the list of files that come from
stdin
.How to simulate
bash
commandline arguments.Add to your websites
/robots.txt
to disable OpenAI's GPT bot from scraping your site.Test NFS locking semantics.
As the user
www-data
run the command php console.php files:scan –all
on the container “nextcloud-app”.Gather facts from all configured hosts (replace all with a hostname to run against a single host).
Print all the IPv4 routes
List all APFS snapshots on local disk; delete a snapshot to free up space and mount a snapshot to recover files.
Gives you NSblahblah-HST (can use IP# too)
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.
Show all grants for the user
iaddressbook
on the host localhost
.Grep my IkiWiki blog for any line beginning with
[[!tag
and strip off the formatting and print out one tag per line.Undocumented pppd feature
To copy a disk image onto a floppy
Show all files belonging to the package org.rudix.pkg.mtr.
Uses mDNS to get a list of all machines on the current subnet.
shows which ntp servers you are connected to
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
lists all redhat packages installed
Case-insensitive searching with
gawk
by setting builtin variable.views a man page without man command
My X console
How to watch POP3 or IMAP4 traffic going to
192.168.1.1
View Caprover logs
Mailman page to modify individual subscriptions
Redirect
stderr
to stdout
Talk dirty to whois
Finds
a.out
executablesShow all TCP traffic on port
80
.Turn on a
systemd
service at book (I think, need to read systemd docs …).Sort of line Linux strace only in a top form and not really the same. Shows information about PID 1234
Converts the IP 10.0.2.254 into hex.
Flush DNS cache on Catalina.
Build a composite docker compose file by overlaying
volumes-cached.yml
over the top of docker-compose.yml
.Broadcast a DHCP client request with the client ID of "heyzeus" and see all responses.
Un-rot13 a message, and it works in pine if you enable the
|
commandUpdate UFW firewall to allow all TCP traffic to ports 80, 443 and 8080-8090 inclusive and adds a comment for the rule.
Remove all falsy values (everything except 🍌).
Broadcast a DHCP client request with a MAC address and see responses from all DHCP servers.
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.
Restart Caprover
Forward all traffic, including DNS, over an ssh tunnel.
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).
installs onto the
/mnt
mounted device using etc/lilo.conf
as the source file.LILO: To get to root without the root password
Change password for user
adam
from the commandline on a Dockerised NextCloud installation.Clone a git repository into a non-empty directory (note that this overwrites exiting files).
If you can’t use
ssh-copy-id
to upload your ssh
key to a remote host you might be able to use this.New tool built into macOS 12 (Monterey) to test quality of internet connection (some details at danpetrov.xyz). #speedtest
Create an SSL certificate for mera using Cloudflare DNS challenge. Format of cloudflare.ini is described here. Requires installing
certbot
and python3-certbot-dns-cloudflare
packages in Ubuntu.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.
Recursively compare two folders and see differences in a format useful to humans.
Dumps the structure and the data of all databases to
mysql_all.sql
(including all the MySql specific create commands)Start up OpenLDAP pointing explicitly to the config file and setting debugging to my preferred setting.
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).Show what package /usr/local/sbin/mtr belongs to.
Trap for signals 1,2,15 and
rm
file if foundChecks (but does not retrieve or delete) messages for
larry@alaska.net
(-k
keeps on server)Resends mail.
Show all files attached to PID
2345
(-R
means include ppid info).Put a <p> at the beginning of every paragraph
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.remove control characters from man output
Shows harrdware information on the primary disk.