Linux 未经许可进入目录

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

cd into directory without having permission

linuxunixpermissionsdirectory

提问by user812954

When cding into one of my directories called openfirethe following error is returned:

cd进入我的目录之一时,openfire返回以下错误:

bash: cd: openfire: Permission denied

Is there any way around this?

有没有办法解决?

采纳答案by user812954

Enter super user mode, and cd into the directory that you are not permissioned to go into. Sudo requires administrator password.

进入超级用户模式,cd进入你没有权限进入的目录。Sudo 需要管理员密码。

sudo su
cd directory

回答by sarnold

You've got several options:

你有几个选择:

  • Use a different user account, one with execute permissions on that directory.
  • Change the permissions on the directory to allow your user account execute permissions.
    • Either use chmod(1)to change the permissions or
    • Use the setfacl(1)command to add an access control list entry for your user account. (This also requires mounting the filesystem with the acloption; see mount(8)and fstab(5)for details on the mount parameter.)
  • 使用不同的用户帐户,该帐户x对该目录具有 e ecute 权限。
  • 更改目录的权限以允许您的用户帐户x执行权限。
    • 或者使用chmod(1)更改权限或
    • 使用该setfacl(1)命令为您的用户帐户添加访问控制列表条目。(这也需要使用该acl选项挂载文件系统;有关 mount 参数的详细信息,请参阅mount(8)fstab(5)。)

It's impossible to suggest the correct approach without knowing more about the problem; why are the directory permissions set the way they are? Why do you need access to that directory?

如果不了解更多问题,就不可能提出正确的方法;为什么目录权限是这样设置的?为什么需要访问该目录?

回答by Jonathan Leffler

If it is a directory you own, grant yourself access to it:

如果它是您拥有的目录,请授予您对它的访问权限:

chmod u+rx,go-w openfire

That grants you permission to use the directory and the files in it (x) and to list the files that are in it (r); it also denies group and others write permission on the directory, which is usually correct (though sometimes you may want to allow group to create files in your directory - but consider using the sticky bit on the directory if you do).

这授予您使用目录及其中的文件 ( x) 并列出其中的文件( ) 的权限r;它还拒绝组和其他人对该目录的写权限,这通常是正确的(尽管有时您可能希望允许组在您的目录中创建文件 - 但如果您这样做,请考虑使用目录上的粘滞位)。

If it is someone else's directory, you'll probably need some help from the owner to change the permissions so that you can access it (or you'll need help from rootto change the permissions for you).

如果它是其他人的目录,您可能需要所有者的帮助来更改权限,以便您可以访问它(或者您需要帮助root来为您更改权限)。

回答by John Riselvato

Unless you have sudo permissions to change it or its in your own usergroup/account you will not be able to get into it.

除非您有 sudo 权限来更改它或其在您自己的用户组/帐户中,否则您将无法进入它。

Check out man chmodin the terminal for more information about changing permissions of a directory.

检查出man chmod在终端有关更改目录权限的详细信息。

回答by Jonathan

@user812954's answer was quite helpful, except I had to do this this in two steps:

@ user812954 的回答很有帮助,但我必须分两步完成:

sudo su
cd directory

Then, to exit out of "super user" mode, just type exit.

然后,要退出“超级用户”模式,只需键入exit.

回答by wcyn

chmod +x openfireworked for me. It adds execution permission to the openfire folder.

chmod +x openfire为我工作。它将执行权限添加到 openfire 文件夹。

回答by howDidMyCodeWork

Alternatively, you can do:

或者,您可以执行以下操作:

sudo -s
cd directory