First, this error is caused by your own carelessness. when creating the file, you use the root permission and find that WQ cannot save and exit after editing in VI. The error e212 is displayed: the file cannot be opened and written. I have not run commands in VI before, and switched to the tailline mode. W! Sudo tee % and press enter to select L as prompted.
The principle of this command is as follows:
Percent sign ("%") indicates the current file name
Follow the prompts in man VIM:
: [Range] W [rite]! {Cmd} Execute {cmd} with [range] lines as standard input (note the space in front of '! '). {Cmd} isexecuted like with ":! {Cmd} ", any '! 'Is replaced withthe previous command': W! Sudo tee % "indicates that the content of the currently edited file is input as a standard input to the sudo tee file name, that is, sudo is saved as the current file name ==== ========================================================== ========================================================== ====================================== I checked the folder permissions later, only the root user has the write execution permission, so the owner chown-r groupname of the folder is changed. username filename can replace the group name, user name, and file name.-R is used to recursively execute commands on all subdirectories or files in the filename folder.