After saving the edited vi file, the system prompts "Can & #39; t open file for writing Press ENTER or type command to continue", viwriting

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.