Subscribe to the feed

Before Python was the ubiquitous multitool of computer programming, Perl was the first choice for hobbyist programmers and lazy sysadmins. Many everyday Linux utilities in use today were written in Perl, so whether you're using Perl as a scripting language or not, you're probably still using Perl programs.

[ Want to test your sysadmin skills? Take a skills assessment today. ]

Perl is easy to overlook because you rarely think about commands in terms of the language they're written in. I sometimes find gems while browsing CPAN (the PyPI of Perl), and here are five of my favorite Perl utilities.

mimetype

A MIME type is a standard way to identify a filesystem entity. On the internet, MIME types help browsers understand what generic icon to assign a file, and they help desktops know what kind of application to use when opening a file.

Unless you use them often, it can be difficult to recall the official MIME type designation for a file type. The Perl script mimetype, in the perl-file-mimeinfo package, provides the quickest and easiest solution:

$ mimetype example.txt
example.txt: text/plain
$ mimetype html/example.webp
html/example.webp: image/webp
$ mimetype mydir
mydir: inode/directory

innotop

You know top, htop, maybe powertop. But if you run databases, then you need to know innotop.

The innotop command monitors a MySQL or MariaDB database, providing performance and I/O statistics (including memory usage and queries processed per second), replication status, a query list, and much more.

You can get innotop from the MariaDB package.

[ Get the MariaDB and MySQL cheat sheet. ]

inxi

Linux has plenty of commands to get a profile of your system. There's lsblk for block devices, free for RAM, ip link for network interfaces, and so on. But if you're looking for a unified command to give you just the information you want, you have to try inxi.

The inxi command gives you the information you expect when you want to get a computer's specs:

CPU: 6-core AMD Ryzen 5 5600X (-MT MCP-)
speed/min/max: 2248/2200/4650 MHz
Kernel: 5.15.38 x86_64
Up: 9h 32m
Mem: 7684.2/32104.6 MiB (23.9%)
Storage: 7.28 TiB (48.1% used)
Procs: 517 Shell: Bash inxi: 3.3.12

Nine times out of 10, that's the information you really mean to get, and inxi provides it in a way that's easy to read and easy to copy and paste.

That's not all inxi does, though. There are plenty of extra options available in its man page. For instance, I do a lot of audio work when I can, so seeing a complete list of audio devices is nice:

$ inxi --audio
Audio:
  Device-1: NVIDIA GP107GL High Definition Audio driver: snd_hda_intel
  Device-2: AMD Starship/Matisse HD Audio driver: snd_hda_intel
  Device-3: Logitech StreamCam type: USB
    driver: hid-generic,snd-usb-audio,usbhid,uvcvideo
  Device-4: Cooler Master CH321 type: USB
    driver: hid-generic,snd-usb-audio,usbhid
  Device-5: Logitech HD Pro Webcam C920 type: USB
    driver: snd-usb-audio,uvcvideo
  Device-6: ZOOM Handy Recorder stereo mix type: USB
    driver: snd-usb-audio
  Sound Server-1: ALSA v: k5.15.38 running: yes
  Sound Server-2: PulseAudio v: 15.0 running: yes

It's a great tool to have on any system, so download inxi now.

[ Get the guide to installing applications on Linux. ]

parallel

I've written about my love of GNU Parallel before, but it's worth another mention. The parallel command literally means you can do more work, faster, with fewer commands.

And it has two separate entry points: You can use it as the recipient of output sent through a Unix pipe or as a standalone command.

As a piped command, the typical start is the find command:

$ find ~/public_html/images -type f -name "*jpg" | \
parallel convert {} {.}.webp

This command finds all JPEG images in the public_html/images/ folder and converts them, in parallel, to WEBP (and swaps the extension .jpg for .webp in the process).

The standalone version of the command looks a little more mysterious if you're not used to it:

$ parallel ffmpeg ~/Audio/file.flac -vn ~/Audio/file.{} ::: ogg m4a opus

This command uses ffmpeg to convert audio to three different formats.

Parallel is a must-have on any system, and it is available from your software repository.

[ Learn how to get more done at the Linux command line with GNU Parallel. ]

exiftool

It happens all the time. A user uploads a photo containing all kinds of potentially sensitive information in its metadata. Nobody gives it a second thought until somebody thinks to dump the EXIF data on the photo, which provides longitude, latitude, dates, and sometimes even more information about the person who took the picture. You can help protect your users (and yourself) by scrubbing EXIF metadata from photos before those photos are made public. The classic tool for that is the Perl script exiftool.

This command removes all metadata from all photos in the ~/public_html/images directory:

$ exiftool -overwrite_original \
-all:all= \
-r ~/public_html/images/

Of course, exiftool is useful for more than just deleting all metadata. You can write new metadata with it or correct metadata that's wrong. For instance, sometimes the EXIF data on a photo asks the photo viewer to rotate the image. When that's not what you want, you can set the Orientation property. There are eight possible values for orientation:

  1. Horizontal (normal)
  2. Mirror horizontal
  3. Rotate 180
  4. Mirror vertical
  5. Mirror horizontal and rotate 270 CW
  6. Rotate 90 CW
  7. Mirror horizontal and rotate 90 CW
  8. Rotate 270 CW

For example:

$ exiftool -Orientation=1 ~/public_html/image/foo.jpg

There are lots of potential properties in EXIF, so it can be difficult to know what values are expected. The exiftool project maintains a friendly conversion table for quick reference.

Perl is a gem

You may not hear as much about Perl as you used to, but that doesn't mean the project's irrelevant. For me, Perl is a great "Bash++" language, with many conventions that feel similar to a C-like or shell scripting language than Python does. Even if you don't intend to write Perl scripts yourself, these five scripts are just the beginning of a collection of amazing utilities you should be using on your system. Try them out!

[ Download now: A sysadmin's guide to Bash scripting. ]


About the author

Seth Kenlon is a Linux geek, open source enthusiast, free culture advocate, and tabletop gamer. Between gigs in the film industry and the tech industry (not necessarily exclusive of one another), he likes to design games and hack on code (also not necessarily exclusive of one another).

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech