Subscribe to the feed

When I first became a sysadmin, I was shocked by the speed and precision that my senior colleagues showed when doing basic tasks inside a given terminal or system. These guys would load up bash keys and have a full-stack health check completed inside of five seconds; all the while, I was still trying to enter the initial SSH keys so that I could even start my work. I knew I was competent on the keyboard and quick to pick up new commands that helped simplify my routine tasks, but I was clearly missing something. I finally pushed past my fear of being the FNG (military-speak for "new guy") and asked the question: "What are you all using to speed through these commands?" Whatever it was, it was clearly automated. That was when a good friend introduced me to a simple but effective tool: AutoHotkey.

AutoHotkey is a free open source tool that's used to script a variety of tasks. Anything, from keyboard shortcuts to launch your favorite browser or keystroke and mouse emulation, can be accomplished with this approachable application. With a detailed and well-thought-out how-to, this tool is something that can be used by senior developers and junior admins alike. All that is needed is a text file containing your scripted shortcuts with the correct file extension (all of this is explained in the how-to that comes along with the AutoHotkey download). Allow me to demonstrate the utility that is on offer here.

For basic, everyday phrases that you use with your customers and co-workers, you might type something like this into your hotkey.ahk file:

---
::gm::good morning!
Return

With the script active, this addition would allow you to enter the gm and good morning! would appear, similar to how we communicate over text but in a professional environment. This next example is a personal favorite of mine, as I am a coffee fiend: 

---
::coffee::be right back, going to grab coffee
Return

As before, the portion contained within the double colon is your keyword. The portion after would be displayed on the screen after hitting the Return/Enter key. Both of these examples are great when used in a conversational context, be it Bluejeans or another conferencing tool. 

At this point, you may be thinking to yourself, "That is just lazy." And, if that is all the program could offer, you would be right. However, this is where the app really earns its keep. For technical or work-related tasks, such as loading SSH keys for a particular user in a terminal, you can script something like: 

---
:://adminkey::ssh-agent bash{Enter}ssh-add /home/admin/.ssh/admin_key{Enter}unset TMOUT{Enter}TERM=xterm-color{Enter}
Return

The simple string //adminkey (Enter) would effectively load your bash and user key, followed by unsetting the timeout value for your login and adding color filters to your terminal (which I find very useful). The other thing that I find myself routinely using is the ability to reduce a long file path down to a few simple letters or keystrokes. 

In this example, we will change directories (cd) to /usr/local/*****/var/mc/server_data/prefs/, which contains a configuration file that I often need to reference in my current position. The file path /usr/local/*****/var/mc/server_data/prefs/ can be shortened to mcprefs.

That script would look something like this:

---
::mcprefs::/usr/local/*****/var/mc/server_data/prefs/
Return

AutoHotkey is a great tool that can be powerful when tuned correctly and can act as a sort of "gateway drug" to further interest in automation solutions (see our articles on Ansible). This tool can be used on an individual basis, and at the end of the day, it will increase your overall efficiency with the time that you are given. When we as sysadmins automate even the simplest of tasks, we increase the amount of time that we can now spend on other things—things like professional development, family time, or perfecting that oatmeal porter you’ve been brewing! Either way, it’s a win in my book.


About the author

Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.

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