Use alias to save time on the Linux/Unix CLI

Use alias to save time on the Linux/Unix CLI

As I was walking down the hall just now, a colleague stopped me to ask if I knew how to set up an alias that would take an argument for printf. I was entirely lost in my own thoughts, nowhere near the topic he had in mind at all, so I just kinda stood there looking at him like he was a little green man fresh off the Martian invaders' spaceship. Attempting to land the plane for me, he scribbled an example on the whiteboard for context ... after making incoherent mumbling sounds, I resumed walking towards the water cooler and filled my bottle. On my way back, I let him know: "I'll see what I can figure out."


Is something like this right off the cuff for you? Or is it a web query/AI interaction?

For me, it only took a quick refresher from my ~/.bashrc to get me back on track. I have so many aliases defined ... sheesh. I forget what some of these are for!

Here's an example of how to solve the problem at hand:

[~]$ alias pr='printf "arg1 arg2 %s\n"'
[~]$ pr arg3
arg1 arg2 arg3
[~]$        

Is that a hammer in search of a nail? Or is that something you might find useful?

There are days when it feels like I'm always banging my head against the wall of deprecated hardware. I try to ssh to old-and-busted and get the dreaded ssh error, Unable to negotiate ... . One of my aliases defined in my bash config is this one:

dumbssh='ssh -o HostkeyAlgorithms=+ssh-dss -o KexAlgorithms=+diffie-hellman-group1-sha1'        

Perhaps a bit childish, definitely passive-aggressive - but old-and-busted deserves no better. So I reach out to the ancient gear (which in Texas slang, we might call a "boat anchor"), like so:

[~]$ dumbssh myuser@old-and-busted        

Until such time as the powers-that-be can authorize the funds to allow me to replace this bodanker* then I get to cope. And being too lazy (𝑬𝑭𝑭𝑰𝑪𝑰𝑬𝑵𝑻!!!) to try to memorize all those options, I edit my bash files and "memorize" the alias instead.

*𝙗𝙤𝙖𝙩 𝙖𝙣𝙘𝙝𝙤𝙧: [boe DAYN kur] a worthless paperweight that belongs at the bottom of the nearest body of water; optionally secured by rope or chain to a water-faring vessel, serving in the capacity of an anchor

What's your daily torture? What alias have you come up with to minimize the pain point?

To view or add a comment, sign in

More articles by Jeffrey Wilson

  • Crafting A Career, Ch 47

    We are not in Kansas anymore. 𝗗𝗼𝗿𝗼𝘁𝗵𝘆 in 𝘛𝘩𝘦 𝘞𝘪𝘻𝘢𝘳𝘥 𝘰𝘧 𝘖𝘻 If you feel like you've conquered all…

  • Crafting A Career, Ch 46

    The Enduring Power of Software Design Patterns In previous chapters I've described some of my first software creations,…

  • Crafting a Career, Ch 45

    My Journey: Learning 𝘎𝘰 as a 𝘗𝘦𝘳𝘭 Veteran Almost 20 years ago, as I wrapped up my MS in Computer Science, Perl…

  • Crafting a Career, Ch 44

    [Review the table of contents to select a different chapter.] When Tech Meets Chaos: Surviving a Network Outage Network…

  • Crafting a Career, Ch 43

    [View the table of contents to select a different chapter.] The Power of Mentorship: Building Networks, Sharing Wisdom,…

    1 Comment
  • Crafting A Career, Ch 42

    [View table of contents to browse other chapters.] Mapping Your Career Path Why Map Your Career? Plans rarely survive…

  • How to leverage AI without losing your voice

    You’ve seen the hype: type a prompt, shove it into your favorite AI chatbot, and bam—content in seconds! Original?…

    3 Comments
  • Crafting a Career, Ch 41

    [Browse other chapters in the table of contents.] No plan survives first contact with the enemy.

  • Advice from a fellow traveler on how to use AI

    [Review my other tutorials.] The hype continues.

  • Crafting a Career, Ch 40

    [Review previous chapters in this series here.] I've started to notice something.

Insights from the community

Others also viewed

Explore topics