After the vi editing file is saved, the system prompts "Can't open file for writing Press ENTER or type command to continue", viwriting
When you use the vi command on linux to modify or edit the content of a file, you can see that <Esc +: + wq!> Unable to save and exit, but the following prompt appears:
E212: Can't open file for writing Press ENTER or type command to continue
There may be two reasons for this error:
1. The current user has insufficient permissions;
2. This file may be used by other programs or users.
The common cause of the error is the former. The solution is to temporarily provide administrator permissions by adding sudo to open the file by using the vi command, for example, opening and editing the file by using the command "sudo vi test.txt.
From this point of view, the sudo command is very useful. When we execute an operating system that prompts insufficient permissions such as "operation not permitted, in most cases, we can add sudo in front of the command to solve the problem of insufficient permissions.
For example, downloading a file from a linux server or uploading a file may prompt that the file may fail to be uploaded directly, but there is no prompt. In this case, check whether the account has insufficient permissions, add sudo.