Home  >  Article  >  Operation and Maintenance  >  How to open a file and save it in linux

How to open a file and save it in linux

王林
王林Original
2019-12-07 14:01:184674browse

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:wSave the file;

Command:qExit.

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 position

Reading 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:

linux tutorial

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn