Work in linux terminal, you can do a little better and faster, if you know a few simple tricks. Consider how fast to run the previous commands, how to search through the command history.
Sorry for the spelling and phonetic errors in the text.
Owner and main writer of MintGuide.org is not a native English speaker.
1. Re-run the command without arguments. Use "!"
!command — used to execute a command with arguments that have been used in the last run.
Suppose we execute some commands and supplemented their arguments. For example, we decided to edit the file myfile.txt in the text editor nano. To do this, we run:
Next, we can execute any more commands, then I want to do nano to open the file myfile.txt. We can use the magic "!". It's enough to write an exclamation point and no space for the command name:
The result will be called the nano command with those arguments with which it was run last time, i.e. in our case !nano would be similar to calling nano myfile.txt.
2. Executing the preceding command. Use "!!"
!! — is used to execute the previous command. Can be used in the text of the other command.
For example, you run the command:
apt-get install mc
And I forgot to write sudo at the beginning. In order not to retype the whole command, you can run:
Note that !! you can use right inside the command text. For example, we will move to the home directory of the user mintguide:
Now go to the folder /home/mintguide/Downloads:
3. Search through the command history. The command "history"
history — command to display history commands, search, and execute previous commands.
If we run history, then the screen will display a list of recently entered commands:
$ history 1 ls 2 sudo sh VBoxLinuxAdditions.run 3 ls 4 pdfposter -p 2x2a4 1111.pdf out.pdf 5 pdfposter -p 2x2a4 1111.pdf 1111.pdf 6 pdfposter -p 2x2a4 1111.pdf 11112.pdf 7 sudo apt-get install photoprint 8 sudo apt-get install posterazor 9 sudo apt-get install cups-pdf 10 sudo apt-get install pdfposter 11 sudo add-apt-repository ppa:damien-moore/ppa 12 sudo apt-get update 13 sudo apt-get install picty 14 sudo apt-get install dcraw totem python-gdata python-flickrapi python-osmgpsmap 15 sudo add-apt-repository ppa:kamalmostafa/fldigi 16 sudo apt-get update 17 sudo apt-get install fldigi
Each command numbered. To call any command from the list, simply execute on the command line: !number. For example the command number 7:
You can specify the number with a minus. For example, running !-2 we will execute before previous command. By running !-1 we will execute the previous command is equivalent to !!, described above.
Search history you can use the grep utility:
history | grep gedit
The history command has several additional features. Read the manual history by running man history.
4. Search history. Ctrl+R
Ctrl+R is the keyboard shortcut that is used to call an "interactive" search in the command history.
Press Ctrl+R while in a terminal. As a result the screen will display a prompt to the search command:
Start typing the initial part or the middle of the command you are looking for. What you type will be in quotes, and after the colon you will be offered a command found in the command history that best satisfies the search. For example, I pressed Ctrl+R and began to enter the apt, and found a command that contains the character apt:
(reverse-i-search)`apt': sudo apt-get install fldigi