Amazon Ubuntu 实例的权限问题
Permissions issue on Amazon Ubuntu Instance
我正尝试在我的实例上获得 ubuntu 适当的权限,以便我可以 运行 rails 服务器。但是,当我更改权限并尝试授予我的 ubuntu 用户 sudo 权限时,它拒绝访问 html 文件夹。我不知道问题可能是什么,因为我尝试将其添加为 sudo 用户,重新启动服务器,但它仍然失败。唯一可行的是将权限更改为我不想要的 777。我不知道为什么 ubuntu 用户权限会按原样运行并拒绝进入该文件夹。任何帮助将不胜感激。
ubuntu@ip-123-123-123-123:/var/www$ sudo chmod -R 644 html/
ubuntu@ip-123-123-123-123:/var/www$ cd html
-bash: cd: html: Permission denied
ubuntu@ip-123-123-123-123:/var/www$ sudo adduser ubuntu sudo
The user `ubuntu' is already a member of `sudo'.
ubuntu@ip-123-123-123-123:/var/www$ sudo cd html/
sudo: cd: command not found
权限文件
ubuntu@ip-123-123-123-123:/var/www$ sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
"sudo ls -ld html"输出
ubuntu@ip-123-123-123-123:/var/www$ sudo ls -ld html/
drw-r--r-- 17 ubuntu root 4096 Feb 7 17:49 html/
"sudo ls -l html/"输出
ubuntu@ip-123-123-123-123:/var/www$ sudo ls -l html/
total 140
drw-r--r-- 10 root root 4096 Feb 7 17:49 app
drw-r--r-- 2 root root 4096 Feb 7 17:49 bin
drw-r--r-- 5 root root 4096 Feb 7 17:49 config
-rw-r--r-- 1 root root 154 Feb 7 17:49 config.ru
drw-r--r-- 3 root root 4096 Feb 7 17:49 coverage
-rw-r--r-- 1 root root 297 Feb 7 17:49 custom_plan.rb
drw-r--r-- 3 root root 4096 Feb 7 17:49 db
drw-r--r-- 3 root root 4096 Feb 7 17:49 doc
-rw-r--r-- 1 root root 4335 Feb 7 17:49 Gemfile
-rw-r--r-- 1 root root 12764 Feb 7 17:49 Gemfile.lock
-rw-r--r-- 1 root root 1201 Feb 7 17:49 Guardfile
-rw-r--r-- 1 root root 72 Feb 7 17:49 instructions
drw-r--r-- 5 root root 4096 Feb 7 17:49 lib
-rw-r--r-- 1 root root 1090 Feb 7 17:49 LICENSE
drw-r--r-- 2 root root 4096 Feb 7 17:49 log
-rw-r--r-- 1 root root 26 Feb 7 17:49 problems_with_dashboard_solutions?
-rw-r--r-- 1 root root 179 Feb 7 17:49 Procfile
-rw-r--r-- 1 root root 210 Feb 7 17:49 project.sublime-project
drw-r--r-- 3 root root 4096 Feb 7 17:49 public
-rw-r--r-- 1 root root 249 Feb 7 17:49 Rakefile
-rw-r--r-- 1 root root 768 Feb 7 17:49 README
-rw-r--r-- 1 root root 12087 Feb 7 17:49 README.rdoc
drw-r--r-- 13 root root 4096 Feb 7 17:49 spec
drw-r--r-- 3 root root 4096 Feb 7 17:49 test
drw-r--r-- 6 root root 4096 Feb 7 17:51 tmp
-rw-r--r-- 1 root root 490 Feb 7 17:49 TODO
-rw-r--r-- 1 root root 513 Feb 7 17:49 Vagrantfile
drw-r--r-- 3 root root 4096 Feb 7 17:49 vendor
-rw-r--r-- 1 root root 470 Feb 7 17:49 zeus.json
为了 cd
进入目录,如果您既不是所有者也不是所有者组的成员,则您需要 5(r-x)
在其他目录中。
示例:
whoami
tiago
sudo mkdir test ; sudo chown root.root test; sudo chmod 644 test
cd test
bash: cd: test: Permission denied
给其他人 5 个:
sudo chmod 645 test
cd test
pwd
/tmp/test
但是把 5(r-x)
给别人是个很糟糕的主意。你最好改变它的所有权:
chown ubuntu.www-data html/
PS。 www-data是apache使用的用户。根据您使用的 Web 服务器,您可能需要选择另一个组。
我正尝试在我的实例上获得 ubuntu 适当的权限,以便我可以 运行 rails 服务器。但是,当我更改权限并尝试授予我的 ubuntu 用户 sudo 权限时,它拒绝访问 html 文件夹。我不知道问题可能是什么,因为我尝试将其添加为 sudo 用户,重新启动服务器,但它仍然失败。唯一可行的是将权限更改为我不想要的 777。我不知道为什么 ubuntu 用户权限会按原样运行并拒绝进入该文件夹。任何帮助将不胜感激。
ubuntu@ip-123-123-123-123:/var/www$ sudo chmod -R 644 html/
ubuntu@ip-123-123-123-123:/var/www$ cd html
-bash: cd: html: Permission denied
ubuntu@ip-123-123-123-123:/var/www$ sudo adduser ubuntu sudo
The user `ubuntu' is already a member of `sudo'.
ubuntu@ip-123-123-123-123:/var/www$ sudo cd html/
sudo: cd: command not found
权限文件
ubuntu@ip-123-123-123-123:/var/www$ sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
"sudo ls -ld html"输出
ubuntu@ip-123-123-123-123:/var/www$ sudo ls -ld html/
drw-r--r-- 17 ubuntu root 4096 Feb 7 17:49 html/
"sudo ls -l html/"输出
ubuntu@ip-123-123-123-123:/var/www$ sudo ls -l html/
total 140
drw-r--r-- 10 root root 4096 Feb 7 17:49 app
drw-r--r-- 2 root root 4096 Feb 7 17:49 bin
drw-r--r-- 5 root root 4096 Feb 7 17:49 config
-rw-r--r-- 1 root root 154 Feb 7 17:49 config.ru
drw-r--r-- 3 root root 4096 Feb 7 17:49 coverage
-rw-r--r-- 1 root root 297 Feb 7 17:49 custom_plan.rb
drw-r--r-- 3 root root 4096 Feb 7 17:49 db
drw-r--r-- 3 root root 4096 Feb 7 17:49 doc
-rw-r--r-- 1 root root 4335 Feb 7 17:49 Gemfile
-rw-r--r-- 1 root root 12764 Feb 7 17:49 Gemfile.lock
-rw-r--r-- 1 root root 1201 Feb 7 17:49 Guardfile
-rw-r--r-- 1 root root 72 Feb 7 17:49 instructions
drw-r--r-- 5 root root 4096 Feb 7 17:49 lib
-rw-r--r-- 1 root root 1090 Feb 7 17:49 LICENSE
drw-r--r-- 2 root root 4096 Feb 7 17:49 log
-rw-r--r-- 1 root root 26 Feb 7 17:49 problems_with_dashboard_solutions?
-rw-r--r-- 1 root root 179 Feb 7 17:49 Procfile
-rw-r--r-- 1 root root 210 Feb 7 17:49 project.sublime-project
drw-r--r-- 3 root root 4096 Feb 7 17:49 public
-rw-r--r-- 1 root root 249 Feb 7 17:49 Rakefile
-rw-r--r-- 1 root root 768 Feb 7 17:49 README
-rw-r--r-- 1 root root 12087 Feb 7 17:49 README.rdoc
drw-r--r-- 13 root root 4096 Feb 7 17:49 spec
drw-r--r-- 3 root root 4096 Feb 7 17:49 test
drw-r--r-- 6 root root 4096 Feb 7 17:51 tmp
-rw-r--r-- 1 root root 490 Feb 7 17:49 TODO
-rw-r--r-- 1 root root 513 Feb 7 17:49 Vagrantfile
drw-r--r-- 3 root root 4096 Feb 7 17:49 vendor
-rw-r--r-- 1 root root 470 Feb 7 17:49 zeus.json
为了 cd
进入目录,如果您既不是所有者也不是所有者组的成员,则您需要 5(r-x)
在其他目录中。
示例:
whoami
tiago
sudo mkdir test ; sudo chown root.root test; sudo chmod 644 test
cd test
bash: cd: test: Permission denied
给其他人 5 个:
sudo chmod 645 test
cd test
pwd
/tmp/test
但是把 5(r-x)
给别人是个很糟糕的主意。你最好改变它的所有权:
chown ubuntu.www-data html/
PS。 www-data是apache使用的用户。根据您使用的 Web 服务器,您可能需要选择另一个组。