The top 3 Linux commands for the summer

Linux is chock full of powerful commands but when you’re staring at a blank command window sometimes it can be a little daunting.

Today, I’m going to show you the top 3 Linux commands you need for the summer.  Whether you’re a seasoned pro and love writing bash scripts or you’re a complete tyro trying to delve into the foreign world of Linux these three commands are absolutely essential and will make you more productive along the way.

1. Know your history

Pop quiz: Who was the 20th President of the United States?

Hmm..

If you’re a history buff that’s an easy one but most of us (including me) can barely recall what happened last night much less over a century ago.  The same logic applies to the the Linux command terminal.

A few weeks ago I showed you how to reset and view your command history but I left out one critical command that can save you hours (okay not hours but maybe just minutes but that doesn’t sound as cool) – can save you hours of frustration.

All your commands are chronicled in .bash_history.  Let’s say you typed something a few days ago but you can’t remember what it was.  Perhaps you were installing something or trying to configure an application but now can’t remember the commands you typed.

Instead of pressing the up arrow a million times to find the command and rather than perusing .bash_history for the command – just type Ctrl + r and start typing the first few characters of the command.

Ctrl + r is like tab complete for history.

For example, let’s say you were fiddling with public and private keys a few weeks ago but couldn’t remember how you deftly copied your local public key to the authorized_keys file on your server.

Linux reverse-i-search via Ctrl and R

  1. Press Ctrl + r
  2. Type “ssh” sans the quotes
  3. Keep pressing Ctrl + r until you find the command
  4. Press Enter to commit

Bam.

2 Yell if you have to

This next one has got to be my favorite Linux command of all time because it’s so succinct and it’s innately funny.

I call it the double bang.  Who knows if that’s the official term or not but it can save you a few keystrokes – okay ONE keystroke but it’s fun to use..

You could tap the up-arrow once and press enter (which is technically only two keystrokes) but double bang is way cooler.

Let’s say you want to find out your Linux distribution.

You type:

cat /etc/*-release

Then you want to print it out again: just press the exclamation point twice and hit enter.

fixedbyvonnie-linux-repeat-last-command

Incidentally, “cat /etc/*-release” prints my Linux version three times for some enigmatic reason.  If anyone knows why please tell me.


Anyway, the double bang thing can be particularly helpful if your logged in as a non-root user and need to use sudo to execute a command with elevated privileges.

For example, let’s say you try to create a file but your denied because you’re logged in as a non-root user.

Here I tried to create a file called test in the root directory but Linux is wisely barking at me about permissions.

Linux Permission Denied

Normally I would:

  1. Press the up arrow key once
  2. Hit the Home button to move the cursor to the start of the line.
  3. Type sudo
  4. Press enter.

Now isn’t that a circuitous path for such a simple task!

With my double bang trick all you have to do is type:

sudo !!

sudo double bang trick

The best part of the command is that it sounds kick ass when you mention it to other techies.

The next time you spot someone going the long way speak up:

Hey man, why are you doing it like that?  Just use the double bang trick.

Smile at the deer-in-the-headlight stares you’ll get.

BAM!!

3. Linux has a sense of humor

Okay this last command, or better said collection of commands, have absolutely zero utility.

They won’t help you get the job done or impress anyone but they’re so funny that I couldn’t resist.

I literally was laughing for 2 solid minutes after I typed these in.


This is the thing: I’m 32 years old, actually 33 – today is my birthday – and you would think I’m more mature than this but I can’t repress my inner teenager who keeps trying to get out.

I’ll give you two funny commands today.  Let’s start with make.

The Linux make command is used to recompile C programs but hilarity ensues when you use it improperly.

If you’re under age 13, please close your eyes and stop reading haha.

Okay, now that my juveniles have left the room type the following and then read the error message:

make love

Linux Make Love

Apparently, Linux isn’t feeling amorous today.

How about this one:

The touch command is used to create new empty files.  For example, if you type:

touch myFile.txt

Linux will create myFile.txt with alacrity.  It’s really convenient and that’s usually what people use it for.

You can even create multiple files by delimiting each character with a space like so:

touch myFile1.txt anotherFile.doc stuff.log

Now we have three empty files sitting in the directory you ran the touch command from:

  • myFile1.txt
  • anotherFile.doc
  • stuff.log

But silly stuff starts happening when you pass in a few invalid commands.

Assuming you’re logged in as a non-root user – type the following:

touch girls\ boo**

touch command fun

You’re basically instructing Linux to create a file called “girls boo**”

The forward slash is there to escape the invisible space character after the slash and the asterisks are supposed be wildcard characters but – in this case – they have the serendipitous effect of resembling censorship!

I couldn’t get over this one.

Alright, that’s it for me.  Do you have any esoteric Linux commands that I overlooked? Please share in the comments!

About

Connect with Vonnie on Twitter

Posted in Linux Tagged with: ,
  • Jorge Edgardo

    Hi Vonnie,

    You have three times the contents of *-release because you have three files named so. Just type ls -la *-release and you’ll see them.

    cat command lets you to concatenate the output of several text files in just one output, something very useful sometimes:

    cat /var/log/messages /var/log/daemon.log /var/log/mail.log | grep -i “error”

    Anyway, thank you for your tutorial on how to repair BCD in Win8. I just use Linux and those things so complex and bloated as Win make me crazy 🙂

    Nice regards,

    Félix