
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
Print headers and contents of whoami.spack.org to standard out, but follow and show any redirects.
Redirect
stderr
to stdout
remove control characters from man output
Remove all falsy values (everything except 🍌).
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
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.similar to stunnel command, much more verbose
Renames all files listed to YYYY-MM-DD_HH-MM-SS (where date is when the picture was taken via EXIF data).
Prints hardware info
Converts the IP 10.0.2.254 into hex.
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.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
).New tool built into macOS 12 (Monterey) to test quality of internet connection (some details at danpetrov.xyz). #speedtest
Print all the IPv4 routes
Load a CSV into an in memory SQLite database and then do a SQL query on the data (details).
Print all information (including IPTC data) to standard out.
sets up stunnel to map ssl traffic coming into 995 to the local pop port unencrypted.
Starts queue runner using alternative directory
Shows harrdware information on the primary disk.
Remove all files which aren't managed by Git.
Displays a macOS notification (can change it to an alert by setting the type of alert for
Script Editor
in System Preferences > Notifications
.Break a lock as root
Deletes file called ”-weirdfile“ in current directory.
Show all TCP traffic on port
80
.Flush DNS cache on Catalina.
Show all grants for the user
iaddressbook
on the host localhost
.Editor roulette, via /u/zebediah49/
Search for the meaning of any OSX error code with 113 in it.
Renames
*.jpg
listed to YYYY/MM/YYYY-MM-DD_HH-MM-SS.Zip the list of files that come from
stdin
.Open an interactive MySQL shell on the container
useful for debugging
ntp
List Homebrew packages which were installed manually (as opposed to pulled in as a dependency of something else).
Broadcast a DHCP client request with a MAC address and see responses from all DHCP servers.
Search the entire drive for files called
core
or dead.letter
which are older then 7 days and delete them.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.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.Snag IMAP usernames and passwords.
List all tags (versions) available for a Docker image at hub.docker.com.
Will work with any ip not just networks
Uses mDNS to get a list of all machines on the current subnet.
Resizes a directory full of images to thumbnail size suitable for incorporating into a “life poster” (see comment by Mark Pilgrim).
Set awk field delimiter to use a character class (be either <space> or <period>).
views a man page without man command
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
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.
Restart Caprover
Finds SUID/GUID files
My X console
Flushes the local DNS cache (useful if you’ve changed mail server IP addresses or something) (pre-Leopard only)
Show what package /usr/local/sbin/mtr belongs to.
Un-rot13 a message, and it works in pine if you enable the
|
commandforges all headers
Shows detailed snapshot of utilization between the time you ran the
statit -b
(begin) and statit -e
(end) commands (only available in priv set advanced
).Provide
ssh
password on commandline so you script commands like rsync
.Disable X11 starting on boot with GDM3 / systemd. Use
get-default
to read current setting. To restore X11 use graphical.target
.Put a <p> at the beginning of every paragraph
Using the BItWarden commandline, print a random passphrase to the screen and save it to the clipboard.
Uses awk to rename all files and get rid of any capital letters.
Use the BitWarden commandline to retrive an item and then
jq
to only print the password. More information at ryan.himmelwright.net.4 pg/pg to printer vger
Upgrade Debian
As the user
www-data
run the command php console.php files:scan –all
on the container “nextcloud-app”.My X console
Update UFW firewall to allow all TCP traffic to ports 80, 443 and 8080-8090 inclusive and adds a comment for the rule.
Turn on a
systemd
service at book (I think, need to read systemd docs …).Use
swaks
(available via Homebrew) to send a TLS encrypted email via smtp.spack.org
to adam@hotmail.com
authenticating as adam@spack.org
via the AUTH LOGIN
mechanism.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.Verbose output including disks, serial numbers, cpu’s etc.
finds/fixes errors in
/etc/passwd
and /etc/shadow
Installs SSH key for passwordless SSH.
Generate a list of all 1Password groups and the vaults which they are mapped to.
LILO: To get to root without the root password
Forward all traffic, including DNS, over an ssh tunnel.
Gives you NSblahblah-HST (can use IP# too)
Tries to run things without the binary modules which will allow to to repair really broken stuff.
Grep my IkiWiki blog for any line beginning with
[[!tag
and strip off the formatting and print out one tag per line.Install the Python package Jupyter using PIP. This works even though jupyter has dependencies which require upgrading the builtin macOS setuptools (which aren’t upgradable because of SIP).
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)Disable’s linux screen saver
Same as above only bind as
uid=adam
and prompt for the password (-w <password>
to specify on the command line)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
Changes users shell to
/bin/bash
(remember root)Runs “notepad my_file.txt” as the user adam on the domain spack.org.
The same as
newaliases
Convert Unix time to normal time.
Broadcast a DHCP client request with the client ID of "heyzeus" and see all responses.
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
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).Run a shell command as root on all servers in the webservers group.
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.Retry a command 5 times, waiting for 15 seconds before retrying.
To get better font rendering on Linux, disable hinting and subpixel rendering, and enable stem darkening by adding this to your
/etc/environment
file.tells all about the package.
Blah
Copy ssh key to leia via the jump host gateway.
Mailman page to modify individual subscriptions
Delete cached files in
~/Library/Caches/Homebrew/
Details of disks and volumes including failed disks, rebuiding disks and hot spares.
Checks (but does not retrieve or delete) messages for
larry@alaska.net
(-k
keeps on server)