10 great and powerful Linux commands you may need to know

 Command line is more powerful because you can do  lot with them,  you can tell your computer exactly what you want and get the appropriate answer.

That is why most of us use the terminal at least once a day. Today we will see another List of useful commands, i`m sure that most of you didn`t hear about them before. Lets see .

1- Run the last command as Root

sudo !!

2- Save a file you edited in vim/vi without the needed permissions

:w !sudo tee %

If you opened a file for edit and when saving you noticed that you forgot to  open file as root, the command above is the solution.

3- Runs previous command but replacing :  “foo” by “bar”


If you did run a long command and you noticed that you made a mistake, to correct the command you can replace only the mistake by the correct word without the need to run the whole command again.

Another alternative to the above command is:


As opposed to ^foo^bar, which only replaces the first occurrence of foo, this one changes every occurrence

4- Short and elegant way to copy or backup a single file before you edit it.

cp filename{,.bak}

5- mtr, better than traceroute and has ping combined

mtr unixmen.com

mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

6- Empty a file without removing it

> file.txt

7- Execute command without saving it in the history


8- Clear a terminal screen


9- List of commands you use most often

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

10- Get your external IP address.

curl ifconfig.me

This is all for today, enjoy

  • AliusPanfilovas

    mtr  great additition to my knowledge list.

  • LinuxGuru4ensics

    Thanks.  Nice article.  Didn’t know #3

  • samuel machua

    Thanks. Didn’t know #10.

  • Unknown

    Command #7 only works if  HISTCONTROL is set to ignorespace.

  • François-Xavier Thomas

    I did know about the others, but #2 and #3 are awesome voodoo magic :)

  • http://chadmccullough.myopenid.com/ Chad McCullough

    There are quite a few in this list that I didn’t know existed. :-)

  • Drew Demarest

    Two and three a such voodoo. But also proof that programmers are lazy! :D

  • Oneoftheevil

     Really cool ist !ssh:p for example . Its just like history |grep “ssh”

  • Tombuben

     you can replace number 8 with a simple command “clear”

    does the same thing.

  • http://twitter.com/shobon (´・ω・)

    The command “clear” takes six keystrokes, including the return key. CTRL+L takes two.

  • Brian Swift

    I prefer this for #9 and other counting tasks.  More processes but less awk code:

    history | awk ‘{print $2}’ | sort | uniq -c | sort -rn | head

  • http://colar.myopenid.com/ Colar

    6 is also “create an empty file”. Shorter than touch.

  • http://vrillusions.com/ Todd Eddy

    Hmm, I just thought of something with  #7.  Make your login password with (at least) one space at the front.  That way if you ever accidentally type your password on the screen (do it more times than I like to admit) then since it begins with a space it won’t show up in history and you don’t need to clean it up later.