1837213 Members
2106 Online
110115 Solutions
New Discussion

changing root's home

 
SOLVED
Go to solution
Fred Martin_1
Valued Contributor

changing root's home

I'm about to change root's home from / to /homeroot.

Can I do this 'on the fly' without troubles, or do I need a reboot, etc?
fmartin@applicatorssales.com
10 REPLIES 10
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: changing root's home

You can change it BUT only those processes started after the change will be aware of the change. The more "standard" name is /root rather than /homeroot but that is up to you.
If it ain't broke, I can fix that.
G. Vrijhoeven
Honored Contributor

Re: changing root's home

Hi Fred,

Yes you can if it is also mounted in /

copy .???* files to roots new home dir.
vipw to add the passwd file
and log in again.


Regards,

Gideon

PS mind the right on roots home dir ( .ssh etc.
Pete Randall
Outstanding Contributor

Re: changing root's home

Fred,

I can't imagine why you couldn't do it on the fly. You will eventually want to make sure you can reboot and log in and all, but, for now, just go ahead and switch it and change the /etc/passwd entry.


Pete

Pete
Prashant Zanwar_4
Respected Contributor

Re: changing root's home

There are no problems with this. You can acheive this using SAM in better way.
You have to take care of the scripts which might be using earlier home of root. for that for now you can create a link to old root home.

Using SAM change root home.

ln -s

This should take care of scripts also which call your root home.
Then over a period of time you can change whereever you are using it.

I have practised it in my setup.

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Robert-Jan Goossens_1
Honored Contributor

Re: changing root's home

Hi Fred,

It is better to use /root. I n case you need to boot in single user mode /home is not available. Create a dir in the root name root.

drwx------ 5 root sys 1024 Sep 29 17:31 root

mv your .profile to /root
edit your profile to change settings to /root. ( like .sh_history )

HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`

change root in the passwd file to the new /root homedir.

Regards,
Robert-Jan
Prashant Zanwar_4
Respected Contributor

Re: changing root's home

Yes before you go for a link create just do

cp -pr /root/* /homeroot

then
mv /root /rootold
ln -s /homeroot /root

This works perfectly.

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Marco Santerre
Honored Contributor

Re: changing root's home

I always change my root's home into /root as soon as I set up a new server. It is recommended that you do that as well. There is no issue in changing the home of root as long as you make sure that all the . files follow and, as mentionned previously, only those processes started after the change will be impacted.
Cooperation is doing with a smile what you have to do anyhow.
Fred Martin_1
Valued Contributor

Re: changing root's home

Thanks all.

I was thinking of /homeroot as I saw it in an HP-UX manual, someplace. If /root is more commonly used then I'll do that.

Fred


p.s. Robert-Jan, I was planning on using /homeroot, not /home/root. I agree, it should be in the root file system, not /home.

fmartin@applicatorssales.com
Ralph Grothe
Honored Contributor

Re: changing root's home

Although all what needs to be done has been said already I'd just like to add

create an new dir in / filesystem (so it is accessible from miniroot in maintenance mode)

mkdir -m 0700 /root

An easy way to move the dot files to the new home is by letting the shell glob them

cd / && mv .[!.]* /root

Change the 6th field in /etc/passwd to the new home by editing /etc/passwd with "vipw" (takes care of advisory file locking)

then logout and in again.
Madness, thy name is system administration
Fred Martin_1
Valued Contributor

Re: changing root's home

Thanks for all the information.
fmartin@applicatorssales.com