"/etc/profile" E212: Can't open file for writing
时间: 2023-09-20 11:13:57 浏览: 233
引用[1]:根据资料显示,当出现"/etc/profile" E212: Can't open file for writing的错误时,可能是由于权限问题导致的。你可以尝试使用以下命令更改文件的权限:sudo chown 用户名:组名 /etc/profile。比如,如果你的用户名是luoji,可以使用sudo chown luoji /etc/profile来更改权限。然后,你可以像在Windows操作系统中一样,右键点击文件,选择properties,然后给予写入权限。这样你就可以成功打开并编辑/etc/profile文件了。[1]
另外,根据引用[2]中的资料,如果你想在Linux系统中安装SPARK并遇到了类似的问题,你可以尝试使用以下命令打开/etc/profile文件:sudo vi /etc/profile。然后,在文件中添加以下内容:
#SPARK_HOME
SPARK_HOME=/home/luoji/JAVA/spark-2.3.1-bin-hadoop2.7
PATH=$SPARK_HOME/bin:$PATH
保存文件后,你应该能够成功打开并编辑/etc/profile文件了。
相关问题
/etc/hosts" E212: Can't open file for writing
根据引用内容,报错"/etc/hosts" E212: Can't open file for writing是由于权限不足导致的。可以尝试使用以下步骤解决该问题:
1. 使用命令"ls -l /etc/hosts"检查文件的权限设置,确保当前用户具有写入该文件的权限。
2. 如果权限不足,请使用命令"sudo chown 用户名:组名 /etc/hosts"更改文件的所有者,比如"sudo chown luoji /etc/hosts"。
3. 确保该文件的所属用户和组拥有写入权限,可以使用命令"ls -l /etc/hosts"检查。
4. 如果权限设置正确,但仍然无法写入该文件,请尝试使用命令"sudo vi /etc/hosts"以root用户身份编辑该文件,并保存更改。
5. 如果以上步骤仍然无法解决问题,请确保磁盘空间充足,并检查文件系统是否处于只读状态。
总的来说,报错"/etc/hosts" E212: Can't open file for writing是由于权限不足或文件系统只读导致的。您可以根据上述步骤尝试解决该问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Centos系统下“无法打开并写入文件”问题的解决](https://download.csdn.net/download/weixin_38622611/14109021)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [sudo vi ~/etc/profile 报错E212:Can't open file for writing](https://blog.csdn.net/weixin_43290383/article/details/82861529)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
root茼蒿使用vim etc/profiel 编辑 出现"/etc/profile" e212: can't open file for writing"错误如何解决
出现 "e212: can't open file for writing" 错误通常是由于该文件没有写权限或正在被其他进程占用。您可以使用以下步骤解决该问题:
1. 确认您是否有编辑该文件的权限。可以使用命令"ls -l /etc/profile"查看该文件的权限设置,如果您没有写入权限,可以使用"sudo chmod +w /etc/profile"命令为该文件添加写入权限。
2. 确认该文件是否正在被其他进程占用。可以使用"lsof /etc/profile"命令查看该文件是否被其他进程打开,如果是,则需要先关闭该进程,然后再进行编辑。
3. 如果以上两个步骤都无法解决问题,可以尝试使用"sudo vim /etc/profile"命令以超级用户身份打开该文件进行编辑。
请注意,在修改系统文件时一定要谨慎操作,以免造成系统不稳定或者出现其他问题。