linux操作提示:“Can't open file for writing”或“operation not permitted”的解决办法


    在linux上使用vi命令修改一个文件内容的时候,发现无法保存,每次写完使用“:q!”命令可以正常退出但是使用":wq!"命令保存文件并退出时出现一下信息提示:

      E212: Can't open file for writing Press ENTER or type command to continue

      出现这个错误的原因可能有两个:
    1.当前用户的权限不足
    2.此文件可能正被其他程序或用户使用。
      一般错误原因都是前者,解决方案是在使用vi命令打开文件时,前面加上sudo来临时提供管理员权限,比如使用命令“sudo vi hosts”打开编辑文件。
     由此看来,sudo命令是很有用的,当我们执行某种操作系统提示诸如“operation not permitted”等权限不足信息时,我们很多时候都可以在命令前面加上sudo来解决权限不足问题。比如当我们从linux服务器上下载某一个文件或上传某一个文件有可能提示这个,也有肯能直接上传不成功但是什么都没提示;这时你就应该想想是不是账号的权限不足,加个sudo试试。
   

转载于:https://www.cnblogs.com/yangkai-cn/p/4016563.html

C:\Users\76805>npm install express -g npm WARN logfile could not create logs-dir: Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_logs' npm WARN logfile could not be created: Error: ENOENT: no such file or directory, open 'C:\Program Files\nodejs\node_cache\_logs\2025-08-17T17_25_44_833Z-debug-0.log' npm WARN logfile could not create logs-dir: Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_logs' npm WARN logfile could not be created: Error: ENOENT: no such file or directory, open 'C:\Program Files\nodejs\node_cache\_logs\2025-08-17T17_25_45_352Z-debug-0.log' npm ERR! code EPERM npm ERR! syscall mkdir npm ERR! path C:\Program Files\nodejs\node_cache\_cacache npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache' npm ERR! [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'mkdir', npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! Log files were not written due to an error writing to the directory: C:\Program Files\nodejs\node_cache\_logs npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
最新发布
08-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值