Pages

Wednesday, June 28, 2017

10 Lesser Known Commands for Linux – Part 3

Overwhelmed with the response of last two articles of “Lesser Known Linux Article” series namely.
  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part 2
  3. 10 Lesser Known Effective Linux Commands – Part IV
  4. 10 Lesser Known Useful Linux Commands- Part V
Lesser Known Linux Commands
10 Lesser Known Linux Commands
We have come up with the third article of this series which includes few other lesser known Linux commands, worth knowing. May be you are already aware of these commands, no doubt you are an experienced Linux user and loves exploration.

22. ^foo^bar Command

Run the last command with modification, in a single instance. Suppose I need to run a command ‘ls -l‘ to long list the content of a directory say ‘Desktop’. Accidentally, you type ‘lls -l‘. So now you will have to retype the whole command or edit the previous command using navigation key. That is painful when the command is long.
avi@localhost:~/Desktop$ lls -l 
bash: lls: command not found
avi@localhost:~/Desktop$ ^lls^ls 
ls -l 
total 7489440 
drwxr-xr-x 2 avi  avi       36864 Nov 13  2012 101MSDCF 
-rw-r--r-- 1 avi  avi      206833 Nov  5 15:27 1.jpg 
-rw-r--r-- 1 avi  avi      158951 Nov  5 15:27 2.jpg 
-rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc
Note: In the above replacement we used “^typo(to be replaced)^original_command”. This command may be very dangerous if you knowingly or unknowingly replaced the typo with system command or anything risky say rm -rf.

23. > file.txt Command

This command flush the contents of a file without the need of removing and creating the same file again. This command is very useful in scripting language when we need an output or log on the same file again and again.
I have a file say ‘test.txt’ on my ‘Desktop‘ with a lot of text.
avi@localhost:~/Desktop$ cat test.txt 
Linux 
GNU 
Debian 
Fedora 
kali 
ubuntu 
git 
Linus 
Torvalds
avi@localhost:~/Desktop$ > test.txt 
avi@localhost:~/Desktop$ cat test.txt
Note: Again, this command can be dangerous, don’t ever try to flush the contents of a system file or configuration file. If you do so, you will be in serious trouble.

      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1nBSYd
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment