applecrusher
applecrusher

Reputation: 5648

Permissions issue on Amazon Ubuntu Instance

I am trying to get my ubuntu proper permissions on my instance so I can run a rails server. However when I changed permissions and tried to give my ubuntu user sudo permissions, it denies access to the html folder. I have no idea what the issue could be as I tried adding it as a sudo user, restarted the server, and it still fails. The only thing that works is changing the permissions to 777 which I do not want. I don't know why the ubuntu user permissions are acting the way they are and denying entry into the folder. Any help would be greatly appreciated.

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

Permissions file

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

The "sudo ls -ld html" output

ubuntu@ip-123-123-123-123:/var/www$ sudo ls -ld html/
drw-r--r-- 17 ubuntu root 4096 Feb  7 17:49 html/

The "sudo ls -l html/" output

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

Upvotes: 0

Views: 216

Answers (1)

Tiago Lopo
Tiago Lopo

Reputation: 7959

In order to cd into a directory, if you're not the owner nor member of the owner group you would need 5(r-x) in others.

Example:

whoami
tiago
sudo mkdir test ; sudo chown root.root test; sudo chmod 644 test
cd test
bash: cd: test: Permission denied

Given 5 to others:

sudo chmod 645 test
cd test
pwd
/tmp/test 

But it's a very bad idea give 5(r-x) to others. You better change it's ownership:

chown ubuntu.www-data html/

PS. www-data is the user used by apache. you may have to choose another group depending on which web server you use.

Upvotes: 2

Related Questions