Home  >  Article  >  Operation and Maintenance  >  What to do if Linux does not save files

What to do if Linux does not save files

藏色散人
藏色散人Original
2020-02-04 09:26:504916browse

What to do if Linux does not save files

What should I do if Linux vi cannot save files?

The solution to the problem that the read-only document cannot be saved when edited by vi in ​​Linux system, use ordinary users to edit configuration files such as nginx.conf:

Recommendation: "Linux Tutorial

What to do if Linux does not save files

When saving, you will be prompted: There is no Root Permission. You can use the following method to solve it: When saving, add:

:w !sudo tee %

What to do if Linux does not save files

In response to the error that vi cannot save files, it is also possible that the current user's sudo permissions are not configured. When using sudo, it prompts "xxx is not in the sudoers file. This incident will be reported. XXX is the user name. , that is, the user name does not have permission to use sudo, just modify the /etc/sudoers file. The following is the modification method:

1. Enter the super user mode. That is, enter "su -", the system will let Enter the super user password. After entering the password, you enter the super user mode.

2. Add write permissions to the file and enter the command "chmod u w /etc/sudoers".

3. Edit/ etc/sudoers file. That is, enter the command "vim /etc/sudoers", enter "i" to enter the editing mode, find this line: "root ALL=(ALL) ALL" and add "xxx ALL=(ALL) ALL below it "(xxx here is your user name), then save (that is, press the Esc key first, and then enter ":wq") to exit.

4. Revoke the write permission of the file. That is, enter the command" chmod u-w /etc/sudoers".

Save again:

What to do if Linux does not save files

#查看是否保存成功:
$grep sudo nginx.conf
#test :w !sudo tee %

The above is the detailed content of What to do if Linux does not save files. 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