Solved

Changing root's home directory

Posted on 2003-10-28
11
1,368 Views
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?
0
Comment
Question by:PsiCop
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 24

Expert Comment

by:shivsa
Comment Utility
try chroot command.
0
 
LVL 34

Author Comment

by:PsiCop
Comment Utility
shivsa,

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.
0
 
LVL 24

Expert Comment

by:shivsa
Comment Utility
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.

0
 
LVL 24

Expert Comment

by:shivsa
Comment Utility
also after changing root dir, vipw will complain all the time, so use usermod command.
0
 
LVL 1

Accepted Solution

by:
riaanvd earned 125 total points
Comment Utility
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.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 7

Expert Comment

by:glassd
Comment Utility
One thing to watch is that root's home directory is still in the root filesystem. The Linux convention of using /root accomplishes that.
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
I'll second glassd'd recommendation of making the homedir /root
0
 
LVL 1

Expert Comment

by:riaanvd
Comment Utility
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.
0
 
LVL 38

Assisted Solution

by:yuzh
yuzh earned 125 total points
Comment Utility
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
daemon:x:1:1::/:/bin/false
..................
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.

Cheers!
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
PS: please remember to put the root's home under the /  filesystem (eg, /dev/dsk/c0t0d0s0,
the first mount filesystem)
0
 
LVL 34

Author Comment

by:PsiCop
Comment Utility
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now