Linux 无法编辑我有写访问权限的只读文件,也无法更改其权限;如何重新挂载其父文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13248439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 17:42:51  来源:igfitidea点击:

Can't edit a read-only file for which I have the write access and also can not change its permission; how to remount its parent folder?

linuxfilepermissions

提问by blackfyre

I need to edit a file which is read only. This file is located at a remote appliance. Through ssh I logged in to this as admin and I have the root access.

我需要编辑一个只读文件。此文件位于远程设备上。通过 ssh,我以管理员身份登录,并且拥有 root 访问权限。

Command "ls -l" show the permissions of file as

命令“ls -l”显示文件的权限为

"-rwxr-xr-x 1 admin root   952 Oct 30 02:01 file.sh"

I am not as such familiar with Linux but I searched and found that this above line means that the admin is the owner and he/she has the read and write permission.

我对 Linux 不太熟悉,但我搜索并发现上面这行表示管理员是所有者,他/她具有读写权限。

But the file is appearing to be read only, I am unable to edit it. So I tried to change the permission using command chomd

但是该文件似乎是只读的,我无法对其进行编辑。所以我尝试使用命令 chomd 更改权限

[admin@appliance targetfolder]# chmod 666 file.sh
chmod: changing permissions of `file.sh': Read-only file system

But still it is just read-only.

但它仍然只是只读的。

Someone suggested to remount the folder which contains this file.

有人建议重新挂载包含此文件的文件夹。

How will I remount it, I used

我将如何重新安装它,我用过

" mount -o remount,rw /folde1/folder2/targetFolder" 

but It gave

但它给了

"mount: can't find /folde1/folder2/targetFolder in /etc/fstab or /etc/mtab".

采纳答案by blackfyre

Problem is solved, I remounted folder by using "mount -o remount,rw /" and then edited the file, without changing any permissions, it worked.

问题解决了,我使用“mount -o remount,rw /”重新挂载了文件夹,然后编辑了文件,没有更改任何权限,它起作用了。