7 amazing Linux commands you didn’t know

Linux is undeniably one of the most important skills for any programmer. The command-line interface not only helps you save time but is also sometimes the only way to do stuff. There are some basic commands which you might be knowing but out here we’ll see some commands which will be one step ahead of these. Please note that all these commands have been tested for ubuntu distribution. So, without further ado, let’s look at the first command.

1) mkdir -p {fol1, fol2}/{fol1, fol2, fol3}

So you may know we use the ‘mkdir’ command to make a directory. But what if we need to make multiple directories and multiple subdirectories for each of the directories? 

We can make use of the argument -p to make the sub-directories. This will take care of all the permutations. So we’ll have fol1 directory which will have fol1, fol2, fol3 directories and fol2 directory which will have fol1, fol2, fol3 directories. You can also create hundreds of folders by just writing 1..100

mkdir -p folder/{1..100}/{1..100}

2) tree

The second is the ‘tree’ command which gives you a nice representation of your subdirectories. It is not present in the terminal by default so you need to install it via sudo apt-get install tree.

And you can see how this works. Pretty neat

tree linux
3) !!

The third is the double exclamation command. This is one of my favorite commands and also a very useful one. It tells the system to redo your last command. The advantage is that you can use it in combination with other commands. For example sudo !! will run the previous command as root!

The single exclamation ! also has an interesting use case. Using ‘history’ you can print the history of command and then select the command which you can to run by ! <sr. no>

!<sr.no> 

For running the nth recent command, you can type

!-<n>      
Example- !-2  (For the second recent command)
4) sudo su

sudo su makes you the root user, so you won’t have to write ‘sudo’ every time you want to run a command as root. So every command is executed with root privileges. To go back you can type ‘exit’ and exit from the root. You should be careful not to damage any important files though!

5)  history          (I have given a single spacebar before history)

For our fifth command, let’s see one to bypass history. As you might know, the ‘history’ command is used to print all the commands you’ve used so far. But what if you don’t want to store the record for a particular command? Now, I don’t know your intentions but you can do it by simply adding a leading space using your spacebar.

Running history again would not have the command in the record.

6) ^string^string2

Let’s move on to the sixth one. If you want to make some changes to your previous command and want to do it in a cool and efficient way, what you can do is type this command ^string1^string2.  ^ is known as the exponent operator.

Here string 1 is the previous command you wish to change and string 2 is the correct command you wanna replace it with.

So lets say I misspelled ‘ecoho’ what I can do it type this command as

^ecoho^echo

^echoho(incorrent spelling) followed by ^echo(correct spelling). Now this would give me the desired output.

7) cmatrix

For the last one, we have ‘cmatrix’. You can install this using sudo apt-get install cmatrix. And when you run it, you get this pretty nice animation of this matrix pattern. And you can press Ctrl + c to exit. Useful? Probably no,… Amazing? Definitely yes!

cmatrix linux

So these are the 7 linux commands you should know. To recap we discussed:

  • Making multiple directories
  • Tree command for a tree representation of your directory
  • Double exclamation to repeat the previous command
  • sudo su to change into the root user, exit‘ to exit
  • Leading space to bypass history
  • Making changes to your previous command using the exponent operator
  • And cmatrix to view a nice animation

So that’s it for the blog post. If you want to check out the video for this post, you can check it out here: https://youtu.be/6_0Ws2kHzE4

11 Comments

  1. erotik

    Awesome post. I am a normal visitor of your web site and appreciate you taking the time to maintain the nice site. I will be a frequent visitor for a long time. Barrie Stern Weissmann

    • hackershrine

      Thanks for the appreciation!

  2. manga wallpaper

    Loving the information on this site, you have done great job on the blog posts. Harrietta Nestor Estren Odelle Tomlin Adamok

  3. LeKE Kremi

    Hi there Dear, are you truly visiting this website on a regular basis, if so after that you
    will without doubt obtain fastidious knowledge.

  4. Leke KREMi

    Heya i’m for the first time here. I came across
    this board and I find It really useful & it helped me out much.
    I hope to give something back and aid others like
    you aided me.

  5. instagram takipçi hilesi

    This paragraph is genuinely a good one it assists new internet users, who are wishing in favor of blogging.

  6. instagram takipçi hilesi

    Thanks in favor of sharing such a nice thought, piece of writing is nice, thats why i have read it entirely

  7. Опсуимолог

    CC

  8. Marti Motorcycle Oil

    Spot on with this write-up, I seriously feel this website needs far more attention. I’ll probably be returning to read more, thanks for the info.

  9. Продать_лекарства

    Spot on with this write-up, I honestly believe this web site needs far more attention.
    I’ll probably be returning to read through more, thanks
    for the advice!

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2024 HACKERSHRINE

Theme by Anders NorenUp ↑