简体   繁体   English

在 chown 和 chmod 之后,用户在文件夹中的权限被拒绝

[英]permission denied in a folder for a user after chown and chmod

I have a directory at我有一个目录在

/home/ec2-user/vertica1

and I'm trying to get user dbadmin all privilages in that folder.我正在尝试让用户dbadmin获得该文件夹中的所有权限。

I've done chown to dbadmin and chmod 777 on that folder but dbadmin still gets a permission denied error.我已经在该文件夹上对 dbadmin 和 chmod 777 进行了 chown,但 dbadmin 仍然收到权限被拒绝的错误。

If I put sudo in front of the command(I put dbadmi in sudoers), then it works.如果我将 sudo 放在命令前面(我将 dbdmi 放在 sudoers 中),那么它就可以工作。 Why can't I get it to work without sudo?为什么没有 sudo 我就不能让它工作?

Can dbadmin traverse /home/ec2-user ? dbadmin 可以遍历/home/ec2-user吗? Try doing chmod a+x /home/ec2-user尝试执行chmod a+x /home/ec2-user

There could be more reasons for being denied, like a specific acl or a LSM but this is the most likely cause.被拒绝的原因可能更多,例如特定的 acl 或 LSM,但这是最可能的原因。

UNIX permissions on directories目录的 UNIX 权限

The UNIX permissions rwx¹ work on directories as follows: UNIX 权限 rwx¹ 对目录的作用如下:

  • r: You can view the contents of the directory (the names of the files or folders inside) R:您可以查看目录中的内容(文件或文件夹的名称内)
  • w: You can create new files, delete or rename existing files. w:您可以创建新文件、删除或重命名现有文件。
  • x: You can traverse the folder. x:可以遍历文件夹。

The traverse permission means that you can access the folder children (assuming you know its name -which you can obtain if you also have read permission-).遍历权限意味着您可以访问文件夹子文件夹(假设您知道它的名称 - 如果您也有读取权限,则可以获得该名称)。

In this case dbadmin could read and traverse / as well as /home, but /home/ec2-user probably had a mode like drwx------ 2 ec2-user in order to protect its contents.在这种情况下,dbadmin 可以读取和遍历 / 以及 /home,但 /home/ec2-user 可能具有类似drwx------ 2 ec2-user的模式以保护其内容。 Thus, even if you had an important file readable by anyone deep inside your home folder, other users can't get into it, since they wouldn't be able to go pass /home/ec2-user (which is exactly what you wanted to do, in this case).因此,即使您的主文件夹深处的任何人都可以读取一个重要文件,其他用户也无法进入它,因为他们无法通过/home/ec2-user (这正是您想要的做,在这种情况下)。

¹ Note that I am skipping over the more exotic ones. ¹ 请注意,我跳过了更奇特的那些。

what is the result of ls -la for this dir and also parent dir? ls -la 这个目录和父目录的结果是什么? Maybe the directory doesn't have read permissions for your user.也许该目录对您的用户没有读取权限。

sudo chmod ug+r vertica1须藤 chmod ug+r vertica1

Also ec2-user directory should be writable by the user dbadmin.此外,用户 dbadmin 应该可以写入 ec2-user 目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM