1

I created a new instance
root@ubuntu-instance:~#

After creating a superuser named T1 I ran:
root@ubuntu-instance:~# su T1

Now I end up with the following:
T1@ubuntu-instance:/root$

Few questions at this point:
1. How come I have access to /root directory even though I am not root user anymore? I thought only root user can have access to the /root directory?

2. Or is it that every superuser/user can have its own /root directory? Because when I checked the content for the .profile file inside the /root directory they were different for root user and the superuser

3. Assuming every superuser can access/have its own /root directory. How do I do access it? Because I ran, sudo cd root but that didn't seem to work.

Thanks much!

1 Answer 1

2
  1. How come I have access to /root directory even though I am not root user anymore? I thought only root user can have access to the /root directory?

That's just because you happened to be in /root when you executed the su command. You will find that you cannot re-access /root once you leave it:

root@t400s:~# pwd
/root
root@t400s:~# su testuser
testuser@t400s:/root$

but

testuser@t400s:/root$ cd ../
testuser@t400s:/$ cd root
bash: cd: root: Permission denied
  1. Or is it that every superuser/user can have its own /root directory?

No.

  1. Assuming every superuser can access/have its own /root directory. How do I do access it? Because I ran, sudo cd root but that didn't seem to work.

That's because cd is a shell builtin command: sudo only works with external executable programs. See for example

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .