Featured »

January 6, 2020 – 12:38 am

I have a squid proxy server that uses a long list of authenticated cache peers in a round-robin configuration. The process looks something like this:

The key to getting this setup working well is to weed …

Read the full story »
Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Archive by Category

Articles in Commands & Shells

Appending Filenames

December 22, 2019 – 9:51 pm
gk5arsj5ijgmshcbh73vvpkdh2k[1]

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

December 19, 2019 – 9:50 pm
Photo-2019-10-07-14-39-03_0266[1]

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

December 16, 2019 – 9:47 pm
4bbqfrqoa4vxlgrr02pg883ozks[1]

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

December 12, 2019 – 9:46 pm
b3gk9tc9x14ki5xa4bx8c4v1b66[1]

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

December 3, 2019 – 9:43 pm
ll7je7yy7kvxsiw8ibssm0nmqf0-2[1]

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

November 30, 2019 – 9:41 pm
gpxvtms6cvea4q504jtbxjfwcd5z-2[1]

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

November 27, 2019 – 9:39 pm
IMG_4678[1]

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

November 25, 2019 – 9:37 pm
gly8stqifn615gp3xbc34h64byx-2[1]

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

August 17, 2019 – 8:04 pm
o42ex2ebr1lhz7wxo84scrr9iuu

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

July 12, 2019 – 7:19 pm
42out6dayezwo4ntrduw5udzq0k-2

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

June 30, 2019 – 11:16 am
sqsb8tfjfhkyxgnmnq8dqzdbbdm

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

June 20, 2019 – 11:09 am
gtmwo2mvag6419w36e4wqir67iu

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

April 20, 2019 – 8:24 pm
Photo-2019-03-25-20-44-06_2465

This is a process and a couple of script to allow you to setup an additional sshd service on an alternate port.

Gnuplot with Bash

April 2, 2019 – 4:08 pm
4804B26A-4735-42D4-AAA8-AF5DAADA39E9

OK, so both of these things have been around forever and will be around long after we’re gone. It’s worth your time to learn how to use the to together.

Multi-Dimensional Arrays in Bash

March 30, 2019 – 4:06 pm
DFBC10D0-9D8E-4A91-996A-CFD4E2CF0487

Bash does not support multi-dimensional arrays, but there is a way to imitate this functionality, if you absolutely have to.

Asciinema Notes

March 27, 2019 – 4:04 pm
4yryncu3ahxlkekwi1mt5kns1i7

Asciinema is an awesome tool for recording your console sessions. It’s great for documenting processes and, in general, showing people how shit works: one look is worth a thousand words, as they say. Unfortunately, I …

Killing Process Network Access

January 27, 2019 – 4:45 pm
IMG_1941[1]

Imagine this scenario: a particular process on your server is connecting to a host outside your internal network and you don’t like that. On the other hand, you can’t just kill that process because you need it.

Installing t CLI power tool for Twitter

January 21, 2019 – 4:41 pm
k0c1xg3f9erebub0aeel9842kih-1[1]

The ‘t’ is an excellent Ruby-based CLI utility for interacting with the Twitter API written by Erik Berlin. This is certainly not the only such tool available, but, in my estimation, it is the most full-featured and expertly-written. No amateur-hour coding here.

Auto-Update /etc/hosts

January 9, 2019 – 4:39 pm
rkhctxih1a1jdqh7x0cgs00ljh5[1]

This was a silly solution to a silly problem, but may come in handy in the future for other things. A user process was establishing frequent connections to a handful of FQDNs. Not having any IP caching capability, every connection attempt was preceded by DNS lookup.

Automating Web Page Screenshots

January 9, 2019 – 4:22 pm
dpu45eapwpze2jks2i1eq930q45

Automatic Web page screenshots are commonly used for various monitoring tasks, such as detecting copyright infringement, website defacement, and other legal and security matters. Automatic screenshotting can also be a useful tool for researchers, developers, and journalists. There are free and open-source tools out there that can help you automate the task of creating Web page screenshots.

AWS CLI Cheat Sheet

August 14, 2018 – 4:18 pm
bb3styfdt6jd861cmp7yt08l1dy

The installation and configuration process for AWS CLI is fairly simple. The package itself is installed with pip (yum -y install python-pip):

Copying X11 Magic Cookies

August 10, 2018 – 4:17 pm
ia2tligtgbuwpu9jmq6i45dw7op

I rarely use GUIs, but when I do, it’s from CLI and every time I run into the annoying MIT-MAGIC-COOKIE-1 data did not match error. It’s easy to fix, but it happens to me so …