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.
- 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 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.
- 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 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.
- avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012
Or
- avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM
Sample output
- -rw-r--r-- 1 avi avi 220492 Nov 1 13:49 Screenshot-1.png
- -rw-r--r-- 1 root root 358 Oct 17 10:11 sources.list
- -rw-r--r-- 1 avi avi 4695982080 Oct 10 20:29 squeeze.iso
- ..
- ..
- -rw-r--r-- 1 avi avi 90624 Nov 5 12:59 Untitled 1.doc
- -rw-r--r-- 1 avi avi 96206 Nov 5 12:56 Untitled 1.odt
- -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.
- avi@localhost:~/Desktop$ tty
-
- /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.
- avi@localhost:/home/avi/Desktop# du -h --max-depth=1
-
- 38M ./test
- 1.1G ./shivji
- 42M ./drupal
- 6.9G ./101MSDCF
- 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.
- avi@localhost:/home/avi/Desktop# expr 2 + 3
- 5
-
- avi@localhost:/home/avi/Desktop# expr 6 – 3
- 3
-
- avi@localhost:/home/avi/Desktop# expr 12 / 3
- 4
-
- avi@localhost:/home/avi/Desktop# expr 2 \* 9
- 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.
- avi@localhost:/home/avi/Documents# look car
- Cara
- Cara's
- …
- ...
- carps
- carpus
- carpus's
- carrel
- carrel's
- carrels
- carriage
- carriage's
- carriages
- carriageway
- carriageway's
- carried
- carrier
- carrier's
- carriers
- carries
- …
- ...
- 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.
- avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to"
-
- Tecmint is one of the best site dedicated to Linux, how to
- Tecmint is one of the best site dedicated to Linux, how to
- Tecmint is one of the best site dedicated to Linux, how to
- Tecmint is one of the best site dedicated to Linux, how to
- …
- …
- ...
- Tecmint is one of the best site dedicated to Linux, how to
- Tecmint is one of the best site dedicated to Linux, how to
- 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.
- avi@localhost:~/Desktop$ factor 22
- 22: 2 11
-
- avi@localhost:~/Desktop$ factor 21
- 21: 3 7
-
- avi@localhost:~/Desktop$ factor 11
- 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 )?
- avi@localhost:~/Desktop$ ping -i 60 -a www.google.com
-
- PING www.google.com (74.125.200.103) 56(84) bytes of data.
- 64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms
- 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.
- avi@localhost:~/Documents$ cat 35.txt
Sample output
- Linux is built with certain powerful tools, which are unavailable in windows.
- 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.
- 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 ).
- <code>avi@localhost:~/Documents$ tac 35.txt </code>
Sample output
- Shell scripting/programming makes it possible to execute command (s), piped to get desired output in order to automate day-to-day usages.
- 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.
- 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/