1. View executed commands (history files)
Executed commands can be selected at the terminal by pressing the UP and DOWN ARROW keys.
Use the history command to list historical commands (save only the most recently used 1000 commands, save your home directory. bash_history file) The front is the label, followed by the content.
! + Label: You can call the command that corresponds to the label displayed by the history command
! + Command First few letters: can call the history command, if there are multiple, then the last one is executed
Gedit. Bash_history Open the History command file, which holds the command before the last shutdown, this command will not be placed in the history command, will be placed in the cache file.
RM ~/.bash_history Delete the history command file. ~ Representative Home Directory
History-c clears the history command for this execution. (Clear Cache)
2.
Ctrl+shift+t: Create multiple labels
ALT + number keys: You can toggle labels
The cache of historical commands in different tags is also different. The cache command is placed in the history command when shutting down (in the order of labels, not in the execution time)
Date: can view time
Date 0911094714 (Month day): Set Date Time
3. File read and write operations
Use VI or VIM command to create or open a file, Vim is a modular VI, it can highlight the text keyword, you can also specify the editing of a language code
VI 123: Open file 123
Three modes: Command mode, insert mode and last line mode
When the file is initially opened, the default is command mode, in command mode, you can do the following:
YY: Copy the line of the current cursor
P: Paste on the next line where the current cursor is located
DD: Deletes the line where the current cursor is located
Nyy: Copy n rows (the line where the cursor is located and the n-1 line below the cursor)
NDD: Delete n rows (the line where the cursor is located and the n-1 line below the cursor)
CC: Cut a row of NCC: Cut n Rows (the line where the cursor is located and the n-1 line below the cursor)
After the cut, the command mode will enter the insertion mode, you need to press the ESC key, after switching back to command mode, you can press the P key to paste
GG: Quickly jump the cursor to the first line from any line
GG: Quickly jump the cursor to the tail line from any line
Home: Quickly jump the cursor to the beginning of the line
End: Quickly jumps the cursor to the end of the line
U undo Action Ctrl+r Cancel (cannot be revoked or canceled after saving)
You can switch from command mode to insert mode by pressing the A,o,i,a,o,i key.
I, match either insert in the word cursor
A, insert the word specifier the cursor
O, the next line where the cursor is inserted (creates a blank line on the next line of the cursor)
I, inserted at the beginning of the cursor
A, insert at the end of the line where the cursor is located
O, insert the previous line in the row where the cursor is located (create a new blank line on the next line of the cursor)
Press the ESC key to return to command mode from insert mode
Can be saved in the last row mode, in command mode, press: Key to switch to the last line mode
: W can save the changes you have made
: Q exit
: Wq Save and exit: Wq=:x
: q! Force quit, do not save
: wq! Force Save exit
:/root Search root (search for input keywords) search for a nonexistent keyword, you can cancel the search
: Set Nu lists line numbers
: 5 cursor moves to 5 lines,: line number, fast switch to specified line
:%s/root/rrrr/g global substitution, replacing root with rrrrr
: 20,50s/rrrrr/root/g replaces the rrrrr in rows 20 through 50 with root% for the entire document, G for global substitution, for all keywords in each line, and if not, to replace only the first keyword of each row
Press the ESC key to switch to command mode from the last line mode.
This article is from the "Raffaele" blog, make sure to keep this source http://raffaele.blog.51cto.com/6508076/1551343
Linux Learning Note 2