[vim] The vim editor reports an error E45: ‘readonly‘ option is set (add ! to override) or E505: xxx is read-only and cannot save the configuration file. Solution (personal test is valid)

After using the vim editor to modify the file and save it, an error E45: 'readonly' option is set (add ! to override) or error E505: "/xxx" is read-only (add ! to override) is reported.

 

Solution:

1. Switch to the root user and try again.

For details on enabling/logging in to the root user, see:

2. Use the system management command sudo

Add sudo before the vim command and reopen the configuration file that needs to be operated.

sudo vim  /etc/profile

Note that using the system management command sudo requires entering the password of the current system user.

 After completing the modification to the configuration file, press the esc key to exit the INSERT mode. In English input, enter ":wq!" to save it successfully.

:wq!

 After successful saving, it will automatically return to the base environment.

 Open the configuration file again through the vim editor

You can see that the modifications have been successfully saved 

Guess you like

Origin blog.csdn.net/weixin_73404807/article/details/134340194