25

You can create a user that has privileges like root, and it's home directory will fall under /home/username. Why does root get its own folder at the top level of the file system? Is this just convention, a security concern, or is there a performance-related reason?

tacos_tacos_tacos
  • 3,220
  • 16
  • 58
  • 97
  • Note that the `root` user and "admin" users are not normally the same thing at all. An "admin" user (assuming this is what you mean by "privileges like `root`") is typically just a regular user that is permitted to execute commands as `root` using something like `sudo`. –  Jun 14 '12 at 13:29
  • Root is `/root`, because that is where the filesystem standard says it should be. :p http://www.pathname.com/fhs/pub/fhs-2.3.html – Zoredache Jun 14 '12 at 22:51

2 Answers2

58

One reason: On many systems, /home is on a separate partition (or network share) that might fail to mount and it is a good idea to allow root to login with his usual environment whenever possible.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • 1
    This is the same reason why most unix systems have /sbin, /sbin and a /usr/bin and /usr/sbin. The first two contain essential binaries to bring the system up and are therefor located on the root filesystem. – Hennes Jun 13 '12 at 17:15
  • 1
    @Hennes you repeated `/sbin` twice what did you mean to say? – tacos_tacos_tacos Jun 13 '12 at 17:34
  • 1
    @jshin47 Same as the second part, without `/usr/`, I would guess. `/bin/` and `/sbin/`. – Izkata Jun 13 '12 at 18:09
  • There is a very good discussion at http://lists.busybox.net/pipermail/busybox/2010-December/074114.html. I think it may have started as a unique user system (the root user) and after some improvements (don't know if Unix refers to `unique user` of some sort) it may have been necessary to add different users with different configurations that need to reside on some other directory. Just guessing. – licorna Jun 13 '12 at 18:50
  • @licorna is the poster in the link you provided questioning the continued necessity of the separation or just saying that it is an artifact that was first continued by convention but is still useful today? – tacos_tacos_tacos Jun 13 '12 at 20:33
  • +1 you always want root's home directory on the boot partition in case of horrible events. The same reason that in traditional unix assigned root's shell by default to a statically linked POSIX shell - don't rely on things that may not be there... – Brian Jun 14 '12 at 00:17
  • @jshin47 the poster in that link is not questioning, but detailing historical circumstances that led to the current state. – licorna Jun 14 '12 at 02:33
  • It is still useful today. The `/usr` tree can be mounted read-only from the network. – Simon Richter Jun 14 '12 at 08:08
  • It won't help you though if logging in as `root` is not possible (e.g. default in Ubuntu), so you'd have to make that possible to benefit from this. – Bart van Heukelom Jun 14 '12 at 11:28
  • Uhmmm, I don't buy it: If things go wrong, I don't care about my root profile. I can live with standard config just during recovery. Furthermore, I also think @BartvanHeukelom has a point. Am I missing something? I'm not a linux expert, but I have checked three of my boxes (Gentoo, Debian, SLES), and all three have only profile stuff in `/root`. – Alberto Jun 14 '12 at 19:18
  • 2
    @Alberto: Unix is *ancient* and the recovery abilities of modern systems couldn't even be imagined back in the days. There are many things in a Unix-like system that would certainly be handled differently from todays perspective. Also, what you put into your root folder is entirely up to you. – Sven Jun 14 '12 at 20:24
  • @SvenW Thanks. I see. So it's a combination of history and convenience, but not a must. I would upvote if you could name one or more examples of what an admin would store in `/root` nowadays... (Perhaps I have to review my habits!) – Alberto Jun 14 '12 at 20:46
  • @Alberto: I don't think there is a best practice and if you are happy the way you work, it's all good. I tend to drop tarballs and rpm/deb files local to a system into this and most important (but luckily nearly ever used) a copy of my config doc tree. This can come handy if I have console access to a machine but the network is down for whatever reason. – Sven Jun 15 '12 at 08:57
7

root's home should be on the partition that the operating system resides on, which by definition is /, so that you can still login as root without issues if, say, another disk partitions are unavailable. /home is sometimes mounted on a separate partition or a separate drive. If this contains the root homedir and is offline, you may encounter difficulties with your login shell. Not a good idea if you're trying to fix things as the root user.

Michael Martinez
  • 2,543
  • 3
  • 20
  • 31