Home >Operation and Maintenance >Linux Operation and Maintenance >What is the command to modify the configuration file in Linux?
What is the command to modify the configuration file in Linux?
Linux generally uses the default VI to add and modify configuration files. Editor, the command is vi file name. Programmers who edit code over time will use more powerful editors.
Briefly introduce how to use the vi editor:
1. vi can be divided into three states, namely command mode (command mode), Insert mode (Insert
mode) and bottom line mode (last line mode). The functions of each mode are distinguished as follows:
1. Command line mode command mode)
Control the movement of the screen cursor, the deletion of characters, words or lines, move and copy a section and enter Insert mode, or go to last line mode.
2. Insert mode
Only in Insert mode, text input can be done. Press the "ESC" key to return to the command line mode.
3. Last line mode
Save the file or exit vi, you can also set the editing environment, such as searching for strings, listing line numbers, etc.
However, in general use, vi is simplified into two modes, that is, the bottom line mode (last line mode) is also included in the
command line mode (command mode).
2. Command mode function keys
1. Insert mode
Press "i" to switch to insert mode "insert
mode", after pressing "i" to enter insert mode, the input file will start from the current position of the cursor;
After pressing "a" to enter insert mode, the file will be input from the position next to the current cursor position. Start inputting text;
After pressing "o" to enter insert mode, a new line is inserted, and text is entered starting from the beginning of the line.
2. Switch from insert mode to command line mode
Press the "ESC" key.
3. Move the cursor
vi can directly use the cursor on the keyboard to move up, down, left, and right, but regular vi uses lowercase English letters "h", "j", "k", "l" controls the cursor to move one space to the left, down, up, and right respectively.
3. vi save command.
Press the ESC key to jump to the command mode, then:
:w Save the file but do not exit vi
:w file Save the modifications to file. Do not exit vi
:w! Force save and do not exit vi
:wq Save the file and exit vi
:wq! Force save the file and exit vi
q: Do not save the file, exit vi
:q! Do not save the file, force exit vi
:e! Abandon all changes, start editing from the last time you saved the file.
Recommended: Linux usage tutorial
The above is the detailed content of What is the command to modify the configuration file in Linux?. For more information, please follow other related articles on the PHP Chinese website!