Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
same question on stackoverflow: stackoverflow.com/q/12228559/7552 –  glenn jackman Sep 1 '12 at 15:00

3 Answers 3

up vote 1 down vote accepted
sudo su - ###gets you to /root, as the root user.
share|improve this answer
sudo su # proper user switch
cd # goes to $HOME by default
share|improve this answer

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.