Linux commands you probably don’t know

Cover Image for Linux commands you probably don’t know

Anyone that’s been using the Linux command line long enough will realise that the learning is never done…

Here are a few more tricks to add to your collection!

Go back a directory


’d yourself to hell and then need to go straight back? Switch back to your last working directory with:

cd -

This is probably my most used recent discovery.

Search for text in a file

Find if there are files containing a particular text

There are plenty of ways to search and find in the command line. But if you want to see if there are files that contain particular text, you can use this command:

grep -Pri Search_Term path_to_directory

Forgot to run sudo before a command?

Forgot to run 

 before a command… I know I have. To run your last command but with 
 just run:

sudo !!

Open an editor to run a command

To open the editor to run a command press 

ctrl + x + e
 together to open up the editor:


This is super helpful when you want to run a multiline command or have an easier time reading a long command.

Hide command from your history

Want to hide your command from your history?

Just add a space before you run your command. There’s a space before the command below, don’t miss it 😉


press up after you have run it and it doesn’t appear… Spooky 😛 Useful if you are running commands you don’t want to be found.

Edit your last command

Ran a really long command and f*cked it up? It’s frustrating having to type it all so just don’t, just type:


This opens up the last command you ran in your terminal editor.

Quickly create folders and sub folders

Want to quickly make some folders and subfolders?


mkdir -p folder/{sub1,sub2}/{nestedInsideBothFolders}


 is important, it creates the parent folder if it doesn’t already exist.

This works with ranges too so if you need 100 folders inside 100 other folders you could run 

mkdir -p folder/{1..100}/{1..100}
I don’t know why you would need that exactly, but it’s nice that you can…

Anything else useful or interesting that you use in the command line?

Written by Niall Maher

Articles and thoughts on running a tech startup and building stuff that people love to use. Founder @ MYQU. Subscribe to my newsletter for new articles and posts I find interesting here.