Operating System - HP-UX
1820206 Members
3791 Online
109620 Solutions
New Discussion юеВ

Re: Newbie Question: Can I change the root user's home dir?

 
Larry Finnegan
Occasional Advisor

Newbie Question: Can I change the root user's home dir?

Seeing all of the dot files and dirs in / for the root user is a little annoying to me. If I change root's home dir to /root and move all the dot files and dir into /root will that cause any problems for the system? It's just an annoyance to me, but it's not critical. My main concern is that if I do this it might hose some binaries that are hardcoded to look for root's home in /. Is this concern warranted? Or should I just edit my /etc/passwd file for the root user?
11 REPLIES 11
James A. Donovan
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

There's no problem in moving root's files to /root and modify /etc/passwd. I never understood why HP didn't do this in the first place....
Remember, wherever you go, there you are...
Patrick Wallek
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

No problem whatsoever in doing that. I actually prefer to move the root home directory to /home/root. That way if I do something stupid and fill up /home, it is not nearly as bad as filling up /.

R. Sri Ram Kishore_1
Respected Contributor

Re: Newbie Question: Can I change the root user's home dir?

Hi,

You can find a good discussion here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=117553

HTH.

Regards,
Sri Ram
"What goes up must come down. Ask any system administrator."
Geoff Wild
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

Sure!

But, in single user mode, /home may not be mounted.

Instead, put it in say /root like what you did.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Patrick Wallek
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

Geoff said: "But, in single user mode, /home may not be mounted."

My reaction is -- so what? I'm not trying to be rude or anything, but it doesn't really make any difference in single user mode. Having root home in /home/root does NOT impact going into single-user mode at all. You may not have your PATH set up and some other minor annoyances, but big deal. Manually mount /home and source your .profile then.

I still feel /home is safer. I honestly don't see where putting roots home in /root gains you anything. It's still in the / mount point and I can still fill up / if I do something stupid.

Just my 2 cents.
Larry Finnegan
Occasional Advisor

Re: Newbie Question: Can I change the root user's home dir?

Very cool. I made the change on all four systems and it makes me feel much better. A little off topic now but, I did note in the other thread pointed out here that someone recommended using 'vipw' to edit /etc/passwd. Any particular reason why that is preferred over using vi and then just using :wq! to save the change?
R. Sri Ram Kishore_1
Respected Contributor

Re: Newbie Question: Can I change the root user's home dir?

From the manpage:
vipw edits the password file while setting the appropriate locks, and does any necessary processing after the password file is unlocked. If the password file is already being edited, you will be told to try again later. The vi editor is used unless the environment variable EDITOR indicates an alternate editor. vipw performs a number of consistency checks on the password entry for root, and does not allow a password file with an incorrectly formatted root entry to be installed.

HTH.
Regards,
Sri Ram
"What goes up must come down. Ask any system administrator."
James A. Donovan
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

Using vipw is preferred a it's safer.

...from the vipw man page...
vipw edits the password file while setting the appropriate locks, and does any necessary processing after the password file is unlocked. If the password file is already being edited, you will be told to try again later. The vi editor is used unless the environment variable EDITOR indicates an alternate editor.

vipw performs a number of consistency checks on the password entry for root, and does not allow a password file with an incorrectly formatted root entry to be installed. To help reduce the possibility of leaving the system in an unbootable state, root's entry is not considered properly formatted if it has a user id that is not zero, or if it has a shell other than /sbin/sh, /usr/bin/csh, /usr/bin/ksh, or /usr/bin/sh.
Remember, wherever you go, there you are...
Sundar_7
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

Patrick,

I do beleive it is not a good idea to have root's home directory in /home filesystem. I agree root's home directory should not be /, but I would prefer /root than /home/root.

One reason being, what if I want to do some maintenance on /home filesystem that requires unmounting the filesystem ?. Thanks for OnlineJFS, we dont have to unmount to extend/reduce the filesystem. But what if I want to do fsck on /home or what if I want to move my /home filesystem from one LV to another ?

What if /home is NFS mounted in an environment ? - You would still like to be able to login as root when your NFS server is unavailable ?. Yeah sure you can login as root even when the home directory is unavailable but what if I have the option set in /etc/default/security not to allow login if the home dir is missing ?

I am sure there are other scenarios that I can think of :-).

- Sundar.
Learn What to do ,How to do and more importantly When to do ?
Patrick Wallek
Honored Contributor

Re: Newbie Question: Can I change the root user's home dir?

Sundar,

If it is an NFS or Automount environment, then I agree root should not be under /home. You also have a good point about the security setting, BUT if /home is not available is multi-user mode, you likely have other problems to worry about.

If you have to perform maintenance on /home, just cd out of it before you start. root would be easy to take care of. I would be more concerned with other users.

I still think it rather pointless to move from / to /root though. I just don't see the benefit.

I think this is an area where we can agree to disagree. :)
Gary L. Paveza, Jr.
Trusted Contributor

Re: Newbie Question: Can I change the root user's home dir?

Just a hypothetical.

What if in /etc/default/security, the following was set:

ABORT_LOGIN_ON_MISSING_HOMEDIR=1 and root's home is /home/root (/home being mounted).

Would root be prevented from loggin in if /home is not mounted?

At least with a home directory of /root (not mounted), if / is not mounted you have much bigger problems than not being able to logon.