Just out of curiosity, I would like to know why, when I log in as root, I am not in /home/user anymore. What's the reason and what does /root directory do exactly?
I'm not an advanced user. Please answer in simple words or give a link that provides clear-cut, simple explanations. I use Ubuntu 16.04 and I log in as root by sudo -i
. As it's explained here, sudo -i
has /root as home. I want to know what the reason is; is there any advantage to be there? And not in ~ like the user of sudo -s
.
Best Answer
You are not logging as root by running a
sudo
command. You are starting a shell with root privileges.If you want to stay in the current user home directory, you can use
sudo -s
instead ofsudo -i
command.cd ~
will take you to the same directory as if you are not in a shell with root privileges. Literally/home/$USER
.When you use
sudo -i
, the system acts as if you are logged in asroot
user. Because of thisbrings you to the root user home directory that is
/root
./root
directory is a home directory for theroot
user.The main difference is that shell settings files like
.bashrc
are used from/root
in case ofsudo -i
, and from a normal user in case ofsudo -s
.