Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot cd into directory in AWS EC2 instance for another user

Not sure if this is the best place to post this question, if not then please point me in the correct direction.

Following these instructions - https://aws.amazon.com/blogs/big-data/running-r-on-aws/ - I have successfully launched R, RStudio Server and Shiny Server on an AWS EC2 (Amazon Linux AMI) instance. When initializing the instance, I created a user and password by adding the lines of code in the user data, as the instructions suggest.

After ssh'ing into my instance, from my home directory, I have the following:

[ec2-user@ip-012-34-56-78 home]$ ls
ec2-user  johndoe  shiny

I am able to cd into the ec2-user directory, however when I try to cd into the johndoe directory, I receive the following error:

[ec2-user@ip-012-34-56-78 home]$ cd johndoe/
-bash: cd: johndoe/: Permission denied

Does anybody know how do I cd into this directory? The article I linked to does not mention it.

Thanks!

like image 923
Canovice Avatar asked May 04 '26 20:05

Canovice


1 Answers

The ec2-user doesn't have permission on that directory. So you have two (or maybe three) choices:

  1. sudo su - to become root. Then you'll be able to go into the directory and do as you see fit.
  2. sudo chmod 755 /home/johndoe which will make that directory world readable.
  3. If the johndoe user is a real user (i.e. has an entry in /etc/passwd) then you can sudo su - johndoe to become that operating system user.

The relative merits of the answers depend on the security that you want in your system. If you just need to look then the first or third answer are likely the best as they are not a persistent change. But if you really want to use that directory by the ec2-user then you may want to use the second answer.

like image 162
stdunbar Avatar answered May 07 '26 12:05

stdunbar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!