Linux Command Line Tips And Tricks: Noobie To Ninja

Ninja noobie commands

OK, there’s a ton of things we could cover here. But let’s just go for some quick wins that will save you a ton of time, and make you look like you know what you’re doing – kind of.

I draw the line at giving away all my secret ninja tips – but these will serve you well 😉

Switch Back To Last Directory

How many times have you copy and pasted the path of the last directory you used..? Or worse, retyped it in full…

When you could have just done this:-

cd -

Home Directory 2 Ways

You might already know this shortcut for the home directory:-

cd ~

But you might not realise you can also just type:-


There you go, saved you 2 key strokes, and raised your ninja profile, marginally.

Listing Directory Contents, The Ninja Way

I’m willing to bet you’ve typed ls -l hundreds of times already. But no more – bet you didn’t know you can get exactly the same results just by typing:-


Go on, I know you’re dying to try that one out ;-). Works for most distros.

Why Wait – Chain Your Commands

You mean you sit there waiting for one command to finish before typing the next one? When you could be having a little nap, or getting a fresh coffee!

Just do this:-

Command1; Command2; Command3

That’s how cli ninjas work – leave your fingers near the keyboard while you snooze, and anyone walking past will think you’re actually working…

Hold On – Surely Chain Commands Only If They Work?

Before you rush out and start applying the tip above, consider this one instead. It only proceeds with the next command if the previous one succeeds:-

Command1 && Command2 && Command3

Now there’s no excuse not to be doing this:-

sudo apt update && sudo apt upgrade

Search Your Previous Commands

You’ll love this one. If you’ve ever been stuck grinding away in a long session, and need to repeat a complicated command you used ages ago, you need this. Yes, you could just hit the up cursor a thousand times and hope you spot it before you die of boredom, or you could use Reverse Search!

All you do is hit:-


Then type in your search term – as you type it will find matches.

Just hit Ctrl+R again to search for the next match. Hit enter to execute the command (and exit the search). Or Ctrl+C to just quit the search.

This one can save your sanity!

Real Time Log Monitoring

Awesome – another snoozing whilst looking like you’re working command.

Or one that’s just really useful when you’re waiting for something specific to happen.

You already know you can use tail to see the latest entries to a log fiel (right?). Well add a switch to that and you can also monitor the latest additions live and as they happen:-

tail -f path_to_the_log_file

Reuse Previous Parameters

No need to keep retyping. No need to copy and paste. Say you just created a directory, mkdir mydirectory, now you want to switch to it. Just use the magic of Alt+. (i.e. the left Alt key plus a full stop):-

cd Alt+. = cd mydirectory

Keep pressing Alt+. to go further back.

Argh, Forgot To Type sudo AGAIN

There are two solutions to this one.

Hit the up cursor, hit Home key, type sudo and enter.

Or here’s the real ninja magic:-

sudo !!

This will repeat the previous command.

There you go – that’s enough ninja secrets for today. Now you can get the Unix Master tattoo… But feel free to add your own favorites in the comments below.