0

The root directory is indicated by / and contains the other directories within it. This also contains a directory called home, which lists the only user on my system, sridhar.

Now there is another directory under / called the root folder directory (not same as / I understand) which I cannot open.

Apparently that contains the home directory of the Super User.

Since there is only 1 user in my system, does that mean the contents of the home/sridhar folder same as the /root folder? What does the /root folder contain?

1

On GNU/Linux there is the standard root user, which always exists, this is different from your user account that you created when you installed Ubuntu.

Your user's home will be in /home/sridhar. The root user's home will be /root

Aside from your user, and the root user there are a great number of other system users too, but these are used to run various background services used by the system only.

If you are familiar with windows the root user is very similar to the Administrator account, it's always there, as a fallback, but in general should only be used when you have to, 99% of the time you should use your regular user account.

--edit

Why do I use sudo every time I install a program?

Only the root user has access to the whole filesystem, which is needed when installing new software into the root (/) filesystem.

Only the root user can install programs and updates??

A regular login user usually only has access to his or her home directory, this prevents the user or a program run by the user from accessing important system files.

If I understand correctly I can never actually login as root.. Only as a user right

You can login as root, sudo -s or sudo su - do this providing a root shell, additionally you could set the root password: sudo passwd root, and then you could log in as root like a normal user - don't do this!

Then why is there a home for the root user?

The root user still needs a home, this is where software looks for config files related to the user's preferences. when you use sudo su - and then run a program, if that program needs a config file, it will likely look in the root users home directory.

--edit again

A final note, the root user can access EVERYTHING, and should not be used for general day to day tasks. If a regular user account is compromised (say a bug in a webbrowser allows an attacker to run code on your machine), then only data in your user directory will be effected, and as a whole the system will be fine, and other users will be fine.

If you we're running your webbrowser as root and an attacker got in, they would be running code as the root user and have access to anything and everything.

  • Why do I use sudo every time I install a program? Only the root user can install programs and updates?? If I understand correctly I can never actually login as root.. Only as a user right. Then why is there a home for the root user? – Sridhar Thiagarajan Jan 5 '16 at 13:23
  • The root user is a user, you can login as root. On Ubuntu the root password is not set, instead they provide the utility sudo which lets you run programs in the context of the root user. You can set the root user's password with sudo passwd root and then you could log in as any use would. By default a login user only has write access to the files under his or her home, but all means you could change this, but it is not advised. The root user is special, it can override and ignore any permissions, as such it is a security nightmare, when using root you should be carefull. – Paul Grove Jan 5 '16 at 14:32
  • I will update my answer since the comment field does not allow me enough room – Paul Grove Jan 5 '16 at 14:34
5

No. You actually have two users: sridhar AND root. The /root folder is the super user's home directory. If you log in as root (this is not possible in Ubuntu by default) and use your programs, the configurations made by the super user will be stored in /root. If you use wine, for example, a wine prefix will be created under /root. So no, the contents from your home directory and /root directory are not the same.

  • Why do i have to use sudo every time i install an update or program?Does this mean i am logging in as root? – Sridhar Thiagarajan Jan 5 '16 at 14:34
  • That's not a particularly simple question to answer, you may want to ask it as a separate question, possibly after doing a search. – thomasrutter Jan 5 '16 at 14:42
  • Wine will refuse to run as root AFAIR – Ruslan Jan 5 '16 at 14:42
  • You have two basic users: your normal user and root. The normal user has powers ONLY in its home user. If you try to do anything outside your home folder you'll be denied. The root user has power over ALL the system (including your home directory) and can basically do anything. Installing software involves writing files to some important system directories, such as /bin, /sbin and /lib, which are outside your home directory. That's why you need to use sudo. By the way, sudo does not log you in as root, it's just a command to run other commands with super user privileges. – Eduardo Cola Jan 5 '16 at 14:51
  • Note that you use your normal user's password (a.k.a. system admin password) to run sudo, not the actual root password. Only the users who belong to the sudoers group can run sudo. The "guest" user cannot run it, since its account is not in sudoers. – Eduardo Cola Jan 5 '16 at 14:53
1
/root

Is the root users home directory, it is not the same as /home/sridhar. The root user has no password set on Ubuntu and you are discouraged from using the root user in preference of the sudo command which allows you to run programs as a super user.

You can in fact use sudo su - to switch to the root user and then use ls /root to peek inside, but you should really use sudo ls /root instead. You will probably be disappointed as there is nothing in there.

0

The /home/<username> directory is the home directory of your user account, and the directory you will use as your home directory.

/root is the home directory of the "root" account, and there is rarely a need to use it.

What is the root account?

The root account is a special account on the system that has all superuser privileges. It's never intended for regular use, only when performing maintenance that requires modifying the system.

On Ubuntu, superuser access is more commonly gained using the sudo command instead of by logging in as the root account. However, it is still possible to log in as the root account, so the system has to have a directory set aside to be the home directory during the period you are logged in as root. It doesn't make sense to store any of your files in there. If you ever use it at all, you could perhaps just use it as a temporary holding place for files you are working on while you are doing things as root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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