
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.
Copy ssh key to leia via the jump host gateway.
Verbose output including disks, serial numbers, cpu’s etc.
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.
Flush DNS cache on Catalina.
Retry a command 5 times, waiting for 15 seconds before retrying.
Installs SSH key for passwordless SSH.
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.Run a shell command as root on all servers in the webservers group.
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
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
Bash function (eg. for
Usage: apt-cache –names-only search redis | flaunt ^redis
~/.bash_profile
) to highlight any matching text. Usage: apt-cache –names-only search redis | flaunt ^redis
Download an archiveable copy of a website using
wget
.Upgrade Debian
Print the list of dates between
2010-01-01
and 2010-01-10
skipping weekends. Just part of the amazing dateutils package.useful for debugging
ntp
blah
Print headers and contents of whoami.spack.org to standard out, but follow and show any redirects.
Case-insensitive searching with awk by forcing $0 to lowercase.
Disable
.DS_Store
and AppleDouble files on network and USB devices.Mailman page to modify individual subscriptions
Load a CSV into an in memory SQLite database and then do a SQL query on the data (details).
List all local snapshots and then delete them.
Restart Caprover
LILO: To get to root without the root password
shows which ntp servers you are connected to
Bootstrap Chezmoi in new ${HOME}. Download binary, install dotfiles from Github user adamshand using SSH authentication, and then delete downloaded binary.
Uses awk to rename all files and get rid of any capital letters.
Reconfigure a Debian system to ask you any configuration a package may want to know (by default it only asks you important questions)
Download the file and keep the file if the transfer gets interrupted allowing it to be resumed where it left off.
installs onto the
/mnt
mounted device using etc/lilo.conf
as the source file.Prints date thirty minutes ago
Un-rot13 a message, and it works in pine if you enable the
|
commandHow to only grep stderr without redirecting all of stderr to stdout. Can use “| tee 2> >(grep …)” on a command which doesn’t support redirection.
Make a /tmp/filename for “search for” and replace it with “replace with”
Finds SUID/GUID files
Only replace
foo.txt
with bar.txt
if it's newer, and backup foo.txt
to foo.txt~#~
before overwriting (where # is an ever incrementing number).Look up TXT records for spack.org using DNS-over-TLS from the DNS server dns.spack.org.
Remove all files which aren't managed by Git.
Finds
a.out
executablesShows the status of currently running disk scrubs.
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.Flushes the local DNS cache (useful if you’ve changed mail server IP addresses or something)
Search for the meaning of any OSX error code with 113 in it.
How to test sending a webhook with cURL.
View Caprover logs
views a man page without man command
Checks (but does not retrieve or delete) messages for
larry@alaska.net
(-k
keeps on server)How to clone a repo and then take it back to a specific branch.
Forward all traffic, including DNS, over an ssh tunnel.
4 pg/pg to printer vger
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).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.(panther) Revert focus follow mouse back to normal off setting by deleting the change.
similar to stunnel command, much more verbose
Case-insensitive searching with
gawk
by setting builtin variable.blah
Shows harrdware information on the primary disk.
Print the last, colon-delimited field of
/etc/passwd
. This works because NF
is the number of fields (eg. 7
for /etc/passwd
) and so this is the same as print $7
.Generate a list of all 1Password groups and the vaults which they are mapped to.
gets enterprise mibs
Watch for traffic to
192.168.1.1
on ports 110
or 143
which start with “user” or contain “login”.same as the host version
Basically chkconfig for OSX,
–list
shows all available services.Zip the list of files that come from
stdin
.Renames all files listed to YYYY-MM-DD_HH-MM-SS (where date is when the picture was taken via EXIF data).
Reset the MBR (master boot record). This doesn’t clear the MBR it restores it to a factory default (or something like that??).
Use
sftp
to connect to leia.spack.org using gateway.spack.org as a jump host.Remove all falsy values (everything except 🍌).
Update UFW firewall to allow all TCP traffic to ports 80, 443 and 8080-8090 inclusive and adds a comment for the rule.
My X console
Add to your
~/.zshrc
and then you can search these gists from the shell with: gists <keyword>
Zsh trick for checking to see if a command exists without spawning a shell.
Boot from USB stick via Grub (details).
Python tool (domainaware/checkdmarc)for looking up DMARC and SPF record and showing any warnings.
Stuff
Test NFS locking semantics.
Print all the IPv4 routes
As the user
www-data
run the command php console.php files:scan –all
on the container “nextcloud-app”.Split
blah.log
into multiple gzip’d files each 1000 lines long.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.
How to break out parts of an absolute file path in Bash.
Download the file to a local name which matches the remote name, and if the download is interupted figure out automatically the offset at which to resume.
Take a screenshot of a website (details).
Use the Bash builtin
time
to see how long a process takes to run. Output is formatted with the TIMEFORMAT
variable (3 decimal places, long format, Elapse time). Details here.Resize the filesystem
/data
(/dev/xvda3
) to a larger than 32bit filesystem. Note the first resize2fs
only converts to a 64 bits, the second actually resizes the filesystem.remove control characters from man output
Start up OpenLDAP pointing explicitly to the config file and setting debugging to my preferred setting.
Show what package /usr/local/sbin/mtr belongs to.
Use
awk
to generate a list of usernames from a CSV list of full names by grepping the passwd
file.Broadcast a DHCP client request with a MAC address and see responses from all DHCP servers.
Recursively copy the contents of WorkPace.app and the resource forks into a compressed CPIO archive.
List all APFS snapshots on local disk; delete a snapshot to free up space and mount a snapshot to recover files.
How to simulate
bash
commandline arguments.Provides a top-like view of network traffic. Shows only TCP traffic on WiFi interfaces from processes named
java
or httpd
.New tool built into macOS 12 (Monterey) to test quality of internet connection (some details at danpetrov.xyz). #speedtest
Converts the IP 10.0.2.254 into hex.