Changing root's home directory

Posted on 2003-10-28
Last Modified: 2013-12-27
I have no desire to change's root's shell, but I'm looking at changing root's home directory on a Solaris v8 box. I want to look into not only the wisdom (or lack thereof) of doing this, but also the practical aspects.

The box is a Solaris v8 with Maintenance Update #7 and the current (10/21/2003) Recommended Patches applied. Among other modifications, I have killed the automounter permanently, as this box will not be NFS-exporting (or importing, for that matter) any of its disks. Hence, my user home directories are in /home, as opposed to /export/home - less typing.

By default, root's home directory is /

However, I don't like this, because if I login under CDE, or use something like Netscape, files (e.g. .Xauthority, the Netscape cache directory, etc.) get put in / - which clutters the place up.

I'd like to create /home/root and make root's home directory there instead. However, if I use vipw to make this change, it yells and screams and jumps up and down - and also won't save the change, claiming I've "mangled" the passwd file.

I understand that if I do this and then lose /home (which is its own slice on a different physical disk than /), I'll be in a pickle and unable to login as root. My BC plan in that case is to boot on the CD-ROM, tickle /etc/passwd back to having root's home directory as /, and then log in normally to start recovery. So I have that angle covered.

Are there any other "gotcha" scenarios that I'm overlooking? Is there any other danger in changing root's home directory? I'd leave the shell as /sbin/sh. Obviously, if I manually do this, I won't be able to use vipw any more. Will admintool get upset?

Has anyone else done this?
Question by:PsiCop
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
LVL 24

Expert Comment

ID: 9634790
try chroot command.
LVL 34

Author Comment

ID: 9635237

Thanks for responding. I don't think you understand what I'm trying to accomplish. I do NOT want root's home dir changed for the duration of one command or script. I want to PERMANENTLY change root's home directory. I don't see how chroot is going to help me do that.
LVL 24

Expert Comment

ID: 9635314
Thanks PsiCop, i totally misunderstood u.

root dir(/) is referenced many places in kernel. i do not know if  u can have a working kernel with root changes to something else.

may be u can try sybolic link or something on running kernel and as u said during boot u have workaround.

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

LVL 24

Expert Comment

ID: 9635405
also after changing root dir, vipw will complain all the time, so use usermod command.

Accepted Solution

riaanvd earned 125 total points
ID: 9635921
Root is just a user as all other users on a system. The difference is that root has a little bit more privileges than the others and that the home dir is /. As you have it covered if your /home fs gets corrupted or lost it will be fine changing root's home dir to /home/root. Use usermod to make the changes or edit the /etc/passwd file directly. The / directory gets referenced in the kernel but the root user gets referenced in the /etc/passwd file like any other user. It's like taking a normal user and give it a uid of 0 in the password file even though it's home dir is /foo/bar, the user will be referenced as Super-User with home dir /foo/bar.

Expert Comment

ID: 9636920
One thing to watch is that root's home directory is still in the root filesystem. The Linux convention of using /root accomplishes that.
LVL 48

Expert Comment

ID: 9637233
I'll second glassd'd recommendation of making the homedir /root

Expert Comment

ID: 9637960
The reason for having it in / is when you have to boot in single user mode, you at least will have a user with Super-User privileges for system maintenance. If the system crash and you have it covered and happy to do a bit of work to get it up and running again, I guess it's fine. The root user will work in another home dir on another fs on another disk but for crash reasons I guess it should be somewhere under the / fs directly. There is nothing that could prevent you from changing it though, because you thought of your recovery process already which will work fine.
LVL 38

Assisted Solution

yuzh earned 125 total points
ID: 9638197
It is very easy to PERMANENTLY change root's home directory. I do it all the time whenever
I install/reinstall a UNIX box, eg, to make root's home dir as /root

mkdir /root     #  create the home dir first

edit /etc/password, to make the root's home as /root,

vi /etc/password

make the entry for root looks like the followings (the 1st line)

root:x:0:1:Super-User Hades:/root:/sbin/sh
fred:x:1001:10:Fred Bush:/export/home/icrawf:/bin/tcsh

You can also put your own version of login scripts, and whatever under the root's home.

LVL 38

Expert Comment

ID: 9638211
PS: please remember to put the root's home under the /  filesystem (eg, /dev/dsk/c0t0d0s0,
the first mount filesystem)
LVL 34

Author Comment

ID: 9639159
OK, I think I have it. I'll scrap my original plan of putting root's home dir in /home and instead create /root on the root filesystem and do it there. I appreciate everyone's input.

Pointwise, I think a split between riaanvd and yuzh is appropriate. Other people contributed but I think those two gave the best Answers. If other folx disagree please say why and I'll reconsider.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question