Ten little-known Linux commands-Part 3

Source: Internet
Author: User

We continue to Part 3 of "10 little-known Linux Command series. Maybe you already know these commands, so you are undoubtedly an experienced Linux user who is interested in exploring them.

22. ^ foo ^ bar command

Run the last modified command in an instance. Suppose I need to run a command 'LS-l' to list the content in the 'desktop 'directory in detail. Unexpectedly, you hit 'lls-l '. So you need to repeat the entire command or use the navigation key to edit the previous command. This is very painful when your command is very long.

 
 
  1. avi@localhost:~/Desktop$ lls -l  
  2. bash: lls: command not found 
  3.  
  4. avi@localhost:~/Desktop$ ^lls^ls  
  5.  
  6. ls -l  
  7. total 7489440  
  8.  
  9. drwxr-xr-x 2 avi  avi       36864 Nov 13  2012 101MSDCF  
  10. -rw-r--r-- 1 avi  avi      206833 Nov  5 15:27 1.jpg  
  11. -rw-r--r-- 1 avi  avi      158951 Nov  5 15:27 2.jpg  
  12. -rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc 

Note:In the above replace, we use "typo (replaced) original_command (original Command )". Warning! This command may be very dangerous! If you intentionally or unintentionally error system commands or any risky commands like rm-rf!

23.> file.txt command

This command will refresh the file content without deleting and then create the same file. This command is useful when we need to output multiple times or record logs on the same file.

I have a lot of text 'test.txt 'files on my 'desktop.

 
 
  1. avi@localhost:~/Desktop$ cat test.txt  
  2.  
  3. Linux  
  4. GNU  
  5. Debian  
  6. Fedora  
  7. kali  
  8. ubuntu  
  9. git  
  10. Linus  
  11. Torvalds 
  12.  
  13.  
  14. avi@localhost:~/Desktop$ > test.txt  
  15. avi@localhost:~/Desktop$ cat test.txt 

Note:Again, this command may be dangerous! Never refresh the system file or the content of a log file. If you do this, you may encounter serious problems!

24. at command

The 'at' command is similar to the cron command and can be used to schedule a task or execute a command at a specific time.

 
 
  1. avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012 

Or

 
 
  1. avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM 

Sample output

 
 
  1. -rw-r--r-- 1 avi  avi      220492 Nov  1 13:49 Screenshot-1.png  
  2. -rw-r--r-- 1 root root        358 Oct 17 10:11 sources.list  
  3. -rw-r--r-- 1 avi  avi  4695982080 Oct 10 20:29 squeeze.iso  
  4. .. 
  5. .. 
  6. -rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc  
  7. -rw-r--r-- 1 avi  avi       96206 Nov  5 12:56 Untitled 1.odt  
  8. -rw-r--r-- 1 avi  avi        9405 Nov 12 23:22 Untitled.png 

Note:Echo "ls-l" means to output this string of commands (here ls-l) on a standard terminal. You can replace 'LS-l' with the command you need or select '.

>: Redirected output

/Dev/pts/0: This is the output device and/or file, which is output to the specified place. Here, it is output to the terminal/dev/pts/0 ).

For me, my tty is at/dev/pts/0. You can run the tty command to check your tty.

 
 
  1. avi@localhost:~/Desktop$ tty  
  2.  
  3. /dev/pts/0 

Note:'At' will be executed as soon as the system time matches to a specific time.

25. du-h-max-depth = 1 command

The following command outputs the subdirectory size of the current directory in the form of human readable.

 
 
  1. avi@localhost:/home/avi/Desktop# du -h --max-depth=1  
  2.  
  3. 38M     ./test  
  4. 1.1G    ./shivji  
  5. 42M     ./drupal  
  6. 6.9G    ./101MSDCF  
  7. 16G . 

Note:The above command is very useful in checking system usage.

26. expr command

'Expr' is not a little-known command. This command is useful when calculating simple arithmetic values in the terminal.

 
 
  1. avi@localhost:/home/avi/Desktop# expr 2 + 3  
  2.  
  3. avi@localhost:/home/avi/Desktop# expr 6 – 3  
  4.  
  5. avi@localhost:/home/avi/Desktop# expr 12 / 3  
  6.  
  7. avi@localhost:/home/avi/Desktop# expr 2 \* 9  
  8. 18 

27. look command

Query words from the English dictionary on the terminal to prevent confusion. For example, I can't remember whether it should be carrier or carieer.

 
 
  1. avi@localhost:/home/avi/Documents# look car 
 
 
  1. Cara  
  2. Cara's  
  3. … 
  4. ...  
  5. carps  
  6. carpus  
  7. carpus's  
  8. carrel  
  9. carrel's  
  10. carrels  
  11. carriage  
  12. carriage's  
  13. carriages  
  14. carriageway  
  15. carriageway's  
  16. carried  
  17. carrier  
  18. carrier's  
  19. carriers  
  20. carries  
  21. … 
  22. ...  
  23. caryatids 

The above command will display all words in the dictionary starting with 'car. I got what I was looking.

28. yes command

Another command is usually not used frequently, but is useful in script language and system management.

This command will continuously output the given string until it is interrupted by your interrupt command.

 
 
  1. avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to"  
  2.  
  3. Tecmint is one of the best site dedicated to Linux, how to  
  4. Tecmint is one of the best site dedicated to Linux, how to  
  5. Tecmint is one of the best site dedicated to Linux, how to  
  6. Tecmint is one of the best site dedicated to Linux, how to  
  7. … 
  8. … 
  9. ... 
  10. Tecmint is one of the best site dedicated to Linux, how to  
  11. Tecmint is one of the best site dedicated to Linux, how to  
  12. Tecmint is one of the best site dedicated to Linux, how to 

29. factor command

Factor is actually a mathematical command. This command outputs the factors of all given numbers.

 
 
  1. avi@localhost:~/Desktop$ factor 22  
  2. 22: 2 11 
  3.  
  4. avi@localhost:~/Desktop$ factor 21  
  5. 21: 3 7 
  6.  
  7. avi@localhost:~/Desktop$ factor 11  
  8. 11: 11 

30. ping-I 60-a IP_address

We use the ping command to check whether the server is connected. I usually ping google to check if I have connected to the Internet.

When you wait for or keep staring at your terminal and wait for a response from a command or a connection to the server, it is sometimes quite irritating.

Once the server is connected, there will be a sound. The following command is to wait 60 seconds for a PING )?

 
 
  1. avi@localhost:~/Desktop$ ping -i 60 -a www.google.com  
  2.  
  3. PING www.google.com (74.125.200.103) 56(84) bytes of data.  
  4. 64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms  
  5. 64 bytes from 74.125.200.103: icmp_req=2 ttl=44 time=281 ms 

Note:When you find that the command does not return sound. Make sure that your system is not muted. The sound is enabled in 'sound preferences (sound options) 'and 'Enable window and window sound' is checked '.

31. tac command

This command is very interesting. It will output the content of the text file in reverse order. That is, from the last row to the first row.

Under the Home Directory, my documentsdirectory contains a 35.txt file. Run the cat command to check the content.

 
 
  1. avi@localhost:~/Documents$ cat 35.txt 

Sample output

  1. Linux is built with certain powerful tools, which are unavailable in windows.
  2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart.
  3. Shell scripting/programming makes it possible to execute command (s), piped to get desired output in order to automate day-to-day usages.

Now you can use the tac command to reverse the file content ).

 
 
  1. <code>avi@localhost:~/Documents$ tac 35.txt </code> 

Sample output

  1. Shell scripting/programming makes it possible to execute command (s), piped to get desired output in order to automate day-to-day usages.
  2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart.
  3. Linux is built with certain powerful tools, which are unavailable in windows.

Now it is over. If you know other Linux commands that are rarely known, you can comment on them below. You can include them in future articles.

Don't forget to give us valuable comments. I will soon send another interesting article. Don't go away and follow Tecmint.

Via: http://www.tecmint.com/10-lesser-known-commands-for-linux-part-3/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.