Linux chmod 一个新安装的外部驱动器来设置写入访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20584032/
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-07 01:38:51  来源:igfitidea点击:

chmod a freshly mounted external drive to set up writing access

linuxunixchmodsuse

提问by zero

I have mounted a external drive at:

我已在以下位置安装了外部驱动器:

# mkdir /mnt/external

and subsequently:

随后:

mkdir -p /mnt/external
mount /dev/sdb1 /mnt/external

Now only the root-user has access to write to these folders.

现在只有 root 用户有权写入这些文件夹。

linux-wyee:/home/martin # dir /mnt
drwxr-xr-x 2 root root 4096 13. Dez 22:01 external

How to change this - how to change that all can write to the external drive. I need to change the permissions within the terminal.

如何更改 - 如何更改所有可以写入外部驱动器的内容。我需要更改终端内的权限。

chmod 777 /dev/sdb1 /mnt/external or something alike -

采纳答案by Balaji Perumal

Try this first,

先试试这个

umount /dev/sdb1

chmod -R 0777 /mnt/external   

then mount with

然后安装

mount /dev/sdb1 /mnt/external

or try

或尝试

chmod -R 0777 /mnt/external

回答by Brandon

chmod -R 777 /mnt/external

No need to specify the device. You chmod the directory recursively.

无需指定设备。您递归地修改目录。

However, usually external drives are formatted with FAT32 or some sort of Windows-compatible file system, which does not have POSIX / UNIX permissions. So this step may be redundant.

但是,通常外部驱动器被格式化为 FAT32 或某种 Windows 兼容的文件系统,它没有 POSIX / UNIX 权限。所以这一步可能是多余的。

How is your drive formatted?

你的驱动器是如何格式化的?

Have you tried writing to it as a non-root user?

您是否尝试过以非 root 用户身份写入它?

回答by Richard Wiseman

I had a similar problem, but the solution for me was to use the uidand gidoptionsof the CIFS filing system. (I had to use CIFS because apparentlyNFS doesn't allow access via username and password, which I needed.)

我遇到了类似的问题,但我的解决方案是使用CIFS 归档系统的uidgid选项。(我不得不使用 CIFS,因为显然NFS 不允许通过我需要的用户名和密码进行访问。)

回答by halfer

A solution posted on behalf of the OP.

代表 OP 发布的解决方案。

Update:

更新:

linux-wyee:/mnt # chown martin:users /mnt/external

See the results: - it is obvious that it works ;-)

查看结果:-很明显它有效;-)

martin@linux-wyee:/> cd mnt
martin@linux-wyee:/mnt> ls -l
insgesamt 4
drwxr-xr-x 3 root root 4096 13. Dez 19:43 external
martin@linux-wyee:/mnt> su
Passwort:
linux-wyee:/mnt # ^C
linux-wyee:/mnt #

linux-wyee:/mnt # chown martin:users /mnt/external

linux-wyee:/mnt # cd mnt
bash: cd: mnt: Datei oder Verzeichnis nicht gefunden
linux-wyee:/mnt # ls -l
insgesamt 4
drwxr-xr-x 2 martin users 4096 13. Dez 22:01 external
linux-wyee:/mnt #

It works as you see now the user martin has got permissions.

正如您现在看到的那样,用户 martin 已获得权限。

回答by Sergey Kochkarev

chmod -R 0777 /mnt/external

chmod -R 0777 /mnt/外部

This seems to be excessive for me. Everyone on this machine can execute whatever he wants from external disk. A wide opened door for hackers. They can e.g. save a picture using a web form, change execute bit and run it as a script on your system.

这对我来说似乎太过分了。这台机器上的每个人都可以从外部磁盘执行他想要的任何操作。为黑客敞开大门。例如,他们可以使用 Web 表单保存图片、更改执行位并将其作为脚本在您的系统上运行。

Perhaps, rw access for owner and group and r for others would be a better option.

也许,所有者和组的 rw 访问权限和其他人的 r 访问权限将是更好的选择。