Home >Operation and Maintenance >Linux Operation and Maintenance >How to open a file and save it in linux
For example, if you want to modify the host file
First use the vi /etc/hosts command to open the reading mode of the hosts file and press the o
key to enter Edit mode and inserts a line after the current position.
After entering the content, press the Esc
key to exit the editing mode and enter the reading mode.
Command:w
Save the file;
Command:q
Exit.
Related video learning tutorial recommendations: linux video tutorial
Edit mode command:
i: Insert # at the current position
##a: Append after the current position o: Insert a line after the current position I: Insert at the beginning of the line A: Append at the end of the line O: Insert a line before the current positionReading mode command:
:w Save file :w filename Save as filename file:q Exit:q! Force exit:w! Force write:wq Save and exit:x Same as wq Recommended related articles and tutorials:The above is the detailed content of How to open a file and save it in linux. For more information, please follow other related articles on the PHP Chinese website!