Articles in Commands & Shells
Generating Random Text Files for Testing
Sometimes you need dummy folder structures populated with random data for testing your various scripts and processes – backups, file transfers, encryption, compression, etc. Every time I need something like this, I end up writing …
Finding Cron Jobs
Cron is an indispensable tool for system administration. The difficulties in working with cron in a large environment stem from its decentralized nature. Cron jobs multiply like rabbits, and keeping track of them is not …
Renaming Files with exiftool
Recently I exported a whole bunch of files from Lightroom to a NAS share and filenames like 2E570434-67B7E0489CA2-39354-000017CF24DD8ACD.jpg are not very informative. It would’ve been nice if the filename contained some useful information like date, …
IP Geolocation from Shell
A handy utility by Rafael Rinaldi called whereami allows you to geolocate an IP address directly from the command line. Here are some quick notes on installing and using this tool.
Approximate String Matching
On occasion I find myself searching for something in log files or in my Bash history, but I can’t quite remember what it is that I am looking for. Come to think of it, this …
Bulk Create Linux Users using Salt
Recently I ran into a situation where hundreds of VMs recently built via OpenShift/Ansible automation were missing an important local user account used for security audits. While our automation guys were working on tracking down …
Coronavirus Stats in Bash
The result of my morbid fascination with the coronavirus situation is this quick bash script that parses Johns Hopkins University coronavirus data to generate a quick report for the current date for the specified countries.
Updating Lynis
Lynis is an excellent security audit tool for Linux and various Unix derivatives. I have a small wrapper script that runs Lynis via a cron job, does a selective diff with the previous run’s output, …
Convert Code Snippets to PNG
On occasion I find myself struggling posting code on discussion forums that don’t handle code formatting all that well. What would’ve helped is some quick and easy way to convert code to an image file …
Appending Filenames
If you google how to append, say, current timestamp to the filename in Bash, almost every suggestion boils down to something really basic along the lines of mv $somefile $somefile_$(date +’Y%-%m-%d’). Technically, this is correct …
Verifying SNMP Connectivity on Multiple Hosts
I needed to check if SNMP was accessible on whatever live servers that existed in a particular subnet. Here’s a quick script to do this.
Selecting Time Ranges from Logs, Part 2
A couple of years ago I wrote an article about selecting specific time ranges from log files. I proposed two options: either convert all timestamps to epoch format (a CPU-intensive process) or rely on regex …
Bulk-Adding IPTables Rules
I’ve been using my mod of this handy script to block countries with iptables. One issue with the script is that it is adding rules one-by-one using the iptables -A syntax. This is the proper …
Detecting Blurry Photos with ImageMagick
Here’s a typical scenario: I go to a birthday party where everyone knows I’m a shutterbug, so I have to bring my camera. As time goes by and blood alcohol concentration rises and attention to …
Working with iptables Logging
Most commonly iptables is used to allow, block, or redirect connections. However, it also has a logging feature that can be very useful for network traffic analysis and system security.
CD/DVD-to-ISO Helper Script
I can’t recall the last time I needed to convert a CD to ISO. I have four laptops and not one even has a DVD drive. It took me a while to find an external …
Analyzing Network Performance
Much of network performance analysis will be comparative in nature. Thus, seeing the output of multiple commands side by side can be quite useful. Bash has a useful little utility called pr and we’ll make …
Copying Data in a Restricted Environment
Consider this not-so-hypothetical scenario: you have some data on server_a that you would like to copy to server_b. Unfortunately, these two servers cannot communicate with each other. Nor do they have access to any common …
IMDb Movie Title Parser in Bash
This is an update to the IMDb parser I wrote years back. From time to time IMDb makes small changes to their setup that break my script. This time they decided to start blocking curl, …
Squeezing Video Files
All that crap I’ve been saving from YouTube, Facebook and whatnot tends to add up. As quality is not a huge concern here (not that it was very high to begin with), optimizing those video …
Adding and Removing sshd instances on CentOS 7
As a follow-up to my previous post about adding sshd instances on CentOS 5 & 6, here’s a script that does the same on RHEL/CentOS 7.
Adding and Removing sshd instances on CentOS 6
This is a process and a couple of script to allow you to setup an additional sshd service on an alternate port.

Latest Comments