Here are some quick tricks to utilise the power of your command lines to the max!
We always say that the most
powerful Linux tools are its Command lines. This is because you can do
about everything right from your command line. You can easily explain
your computer exactly what you require and it comes back to you with
appropriate results. Infact there are some commands that make this tool
even more powerful!
Here are 10 commands that work like energy drinks for you Linux machines!
1. Runing the last command as Root
sudo !!
2. To find your external IP address.
curl ifconfig.me
Also if you want to open some file to make changes and right when want to save it, you realise that you forgot to open it as root, there is nothing to worry. The command above is your solution.
3. Run your previous command with replacing “foo” with “bar”
^foo^bar
Or alternatively you can use the below command:
!!:gs/foo/bar
Also after running a long command, if you realise that you have made a mistake, this command helps you replace that one word instead of running the whole command again, unlike the previous command which can only replace foo.
4. Auto-empty any file without removing it
> file.txt
5. Execute command without saving it in the history
command
6. Slick way to copy or backup a file before you edit it.
cp filename{,.bak}
7. Traceroute is a nice command but how about a single network diagnostic tool that can combine traceroute with ping? mtr is your command.
mtr efytimes.com
8. To Clear your terminal's screen
ctrl-l
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. Saving the file you edited in vim/vi without the required permissions
:w !sudo tee %
Here are 10 commands that work like energy drinks for you Linux machines!
1. Runing the last command as Root
sudo !!
2. To find your external IP address.
curl ifconfig.me
Also if you want to open some file to make changes and right when want to save it, you realise that you forgot to open it as root, there is nothing to worry. The command above is your solution.
3. Run your previous command with replacing “foo” with “bar”
^foo^bar
Or alternatively you can use the below command:
!!:gs/foo/bar
Also after running a long command, if you realise that you have made a mistake, this command helps you replace that one word instead of running the whole command again, unlike the previous command which can only replace foo.
4. Auto-empty any file without removing it
> file.txt
5. Execute command without saving it in the history
command
6. Slick way to copy or backup a file before you edit it.
cp filename{,.bak}
7. Traceroute is a nice command but how about a single network diagnostic tool that can combine traceroute with ping? mtr is your command.
mtr efytimes.com
8. To Clear your terminal's screen
ctrl-l
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. Saving the file you edited in vim/vi without the required permissions
:w !sudo tee %
Comments
Post a Comment