I want to access root user's home directory /root/. However following commands dont lead me to the root directory.

sudo -s

cd ~

It leads to the home dir of regular user. How to access /root when using sudo -s to login as root. I am using bash4 on ubuntu12.04.


3 Answers 3

sudo su - ###gets you to /root, as the root user.

Simply use cd /root if you just want to go there :)

sudo -s may not update all environment variables so some aspects of your shell is still the old one. You can use sudo -i, or one of the methods described in How do I run a command as the system administrator (root).

sudo su # proper user switch
cd # goes to $HOME by default

You must log in to answer this question.

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