
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
Renames all files listed to YYYY-MM-DD_HH-MM-SS (where date is when the picture was taken via EXIF data).
Provides a top-like view of network traffic. Shows only TCP traffic on WiFi interfaces from processes named
java
or httpd
.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.Generate a list of all 1Password groups and the vaults which they are mapped to.
Upgrade Debian
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.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.
Zsh trick for checking to see if a command exists without spawning a shell.
Blah
similar to stunnel command, much more verbose
shows which ntp servers you are connected to
To get better font rendering on Linux, disable hinting and subpixel rendering, and enable stem darkening by adding this to your
/etc/environment
file.Set awk field delimiter to use a character class (be either <space> or <period>).
LILO: To get to root without the root password
Use
sftp
to connect to leia.spack.org using gateway.spack.org as a jump host.Download an archiveable copy of a website using
wget
.Dumps the structure of the
drupal
database to drupal.sql
.New tool built into macOS 12 (Monterey) to test quality of internet connection (some details at danpetrov.xyz). #speedtest
Take a screenshot of a website (details).
Converts the IP 10.0.2.254 into hex.
Add to your
~/.zshrc
and then you can search these gists from the shell with: gists <keyword>
Download the file and keep the file if the transfer gets interrupted allowing it to be resumed where it left off.
sets up stunnel to map ssl traffic coming into 995 to the local pop port unencrypted.
Shows temp and stuff
How to clone a repo and then take it back to a specific branch.
Watch for traffic to
192.168.1.1
on ports 110
or 143
which start with “user” or contain “login”.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.
Look up TXT records for spack.org using DNS-over-TLS from the DNS server dns.spack.org.
Update UFW firewall to allow all TCP traffic to ports 80, 443 and 8080-8090 inclusive and adds a comment for the rule.
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
List all local snapshots and then delete them.
Flushes the local DNS cache (useful if you’ve changed mail server IP addresses or something)
Retry a command 5 times, waiting for 15 seconds before retrying.
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).blah
Broadcast a DHCP client request with a MAC address and see responses from all DHCP servers.
Use
awk
to generate a list of usernames from a CSV list of full names by grepping the passwd
file.View Caprover logs
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.
Connect to
smtp.spack.org:587
and initiate an SMTP STARTTLS session. More OpenSSL examples here.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.Verbose output including disks, serial numbers, cpu’s etc.
tells all about the package.
List all APFS snapshots on local disk; delete a snapshot to free up space and mount a snapshot to recover files.
Show what package /usr/local/sbin/mtr belongs to.
Test NFS locking semantics.
Print the list of dates between
2010-01-01
and 2010-01-10
skipping weekends. Just part of the amazing dateutils package.(panther) Revert focus follow mouse back to normal off setting by deleting the change.
Search for the meaning of any OSX error code with 113 in it.
same as the host version
Python tool (domainaware/checkdmarc)for looking up DMARC and SPF record and showing any warnings.
useful for debugging
ntp
Case-insensitive searching with awk by forcing $0 to lowercase.
Stuff
Reconfigure a Debian system to ask you any configuration a package may want to know (by default it only asks you important questions)
Remove all files which aren't managed by Git.
remove control characters from man output
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.
Split
blah.log
into multiple gzip’d files each 1000 lines long.4 pg/pg to printer vger
Shows the status of currently running disk scrubs.
How to simulate
bash
commandline arguments.Disable
.DS_Store
and AppleDouble files on network and USB devices.Uses awk to rename all files and get rid of any capital letters.
As the user
www-data
run the command php console.php files:scan –all
on the container “nextcloud-app”.Disable’s linux screen saver
views a man page without man command
Create a RAM disk (
tmpfs
) with a maximum size of 50MB and read/write only by root (default is mode 1777
). See /usr/src
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).gets enterprise mibs
Remove all falsy values (everything except 🍌).
Recursively copy the contents of WorkPace.app and the resource forks into a compressed CPIO archive.
blah
Clone a git repository into a non-empty directory (note that this overwrites exiting files).
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.Dumps the structure and the data of all databases to
mysql_all.sql
(including all the MySql specific create commands)Resizes a directory full of images to thumbnail size suitable for incorporating into a “life poster” (see comment by Mark Pilgrim).
Zip the list of files that come from
stdin
.Convert Unix time to normal time.
Mailman page to modify individual subscriptions
Disable X11 starting on boot with GDM3 / systemd. Use
get-default
to read current setting. To restore X11 use graphical.target
.Download (if necessary) the
zabbix/zabbix-appliance:latest
image and name it zabbix-appliance
locally. Map container ports 10051/80 to 1051/81 respectively (so that external port 81 routes to internal container port 80)Put a <p> at the beginning of every paragraph
List all tags (versions) available for a Docker image at hub.docker.com.
Details of disks and volumes including failed disks, rebuiding disks and hot spares.
Lists all required software updates from the AppleOsx site. You can also use it to install the packages.
Takes standard in (from
echo
in this case) and replaces all instances of foo
with BAZ
.Talk dirty to whois
installs onto the
/mnt
mounted device using etc/lilo.conf
as the source file.Use the BitWarden commandline to retrive an item and then
jq
to only print the password. More information at ryan.himmelwright.net.(MacPorts) Upgrade subversion to the latest version (without “-u” the old version won’t be uninstalled automatically)
create and mount a ramdisk
Add to your websites
/robots.txt
to disable OpenAI's GPT bot from scraping your site.Download a web page to stdout, number all the spans with a class of
time-text
and pull out the text within the span’s with a class of time-text
Puts line matching
/DAILY/
into $x
, then skips to the next line and prints $x
followed by the next line. Useful for generating reports when each log entry spans two lines. Eg. line 1 and 2 get merged into line 1, and line 3 and 4 get merged into line 2 etc. (from Shannon)Run a shell command as root on all servers in the webservers group.
Search all the data files in Sendmail’s queue for null characters and remove them. This very useful when spurious null characters crash your Cyrus LMTP process and cause your sendmail queue to backup forever.
Reset the MBR (master boot record). This doesn’t clear the MBR it restores it to a factory default (or something like that??).
Broadcast a DHCP client request with the client ID of "heyzeus" and see all responses.
Finds
a.out
executablesIf you really can’t delete a file any other way.
ls -id
means don’t go into directories and print out the inode of each file. Then we take the inode of the weird file and tell find to delete that inode.