Operating System - HP-UX
1834750 Members
2989 Online
110070 Solutions
New Discussion

Re: Change root home directory

 
SOLVED
Go to solution
Dewa Negara_4
Regular Advisor

Change root home directory

Hi All,

Pls help.

I have this line on my /etc/passwd :
root:*:0:3::/:/sbin/sh

How can I change the root home directory "/" to "/root" using command line without editing /etc/passwd using vi editor or vipw?

Pls help. High core will be given.

Thanks and Best Regards,
Negara


Santos
5 REPLIES 5
Con O'Kelly
Honored Contributor
Solution

Re: Change root home directory

Hi

Do the following:

# mkdir /root
# chmod 700 /root
Edit /etc/passwd file and change / to /root (use vipw command to edit /etc/passwd)
# vipw
# mv /.profile /root/.profile

Move any other files that belong in root's home directory to new home directory.

If trusted system run:
# pwconv

I'd also advise keeping an extra session logged into root just to ensure there is no problems.

Cheers
Con


Mei Jiao
Respected Contributor

Re: Change root home directory

You can use SAM to do the above, if you don't want to manually edit /etc/passwd file.

SAM
--> Accounts for Users and Groups
--> Users
--> Highlight root
--> Action menu
--> Modify
--> Make changes on 'Home Directory' to /root
--> OK
Sanjay Kumar Suri
Honored Contributor

Re: Change root home directory

Just check if usermod command helps:

usemod -d /root root

Ensure that /etc/securetty has entry console, so that in case of any issue you can login using console.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Michael Tully
Honored Contributor

Re: Change root home directory

You can't do it without actually editing the /etc/passwd as part of the process. (vipw is necessary as it locks the file) I would suggest strongly against using 'awk' or 'sed'.
The rest of the process has been identified by Con.
Anyone for a Mutiny ?
Dewa Negara_4
Regular Advisor

Re: Change root home directory

Hi All,

Thanks for all comments. I decided to use vipw to edit /etc/passwd.

Thanks again.

Best Regards,
Negara
Santos