Wednesday, June 9, 2010

Creating a home directory for root in Solaris 10

Abstract: In Solaris 10, '/' is the default home folder for root. While effective, it's also messy, allowing root's personal files and directories to intermix with the system files. The following explains how to clean up the '/' directory and is easiest if done immediately after installing Solaris. Before starting: you'll need root access to complete the following and you should decide on the new root folder location.
Recommended root folder locations:
/root (the one used later in this post)
/export/home/root (consistent with other user home directories on the system)

Login: non-root account
(Create one with the useradd command as root if necessary.)

$ su
Password: root-password
# usermod -d /root -m root
# exit


What just happened:

su assumed super user role

usermod -d /root -m root modified the root account with these options:

-d /root root's new directory is /root

-m makes(creates) the new directory

root user account that is modified

exit some changes can't be made while the user is logged in

Now to move root's personal files to the new home folder.

# ls -al /
# mv root-personal-files
# cp possible personal files

Examine the 'ls -al /' results. Leave everything owned by 'sys' in the / directory.
Directories: most directories in /, especially large ones with lots of sub-directories, stay in /. If you think but aren't sure that a directory belongs in the new home directory, leave a copy in / and put a copy the new home directory.
Individual files: especially .files like .profile probably belong in your folder.

2 comments:

  1. In Solaris 10 10-09 I've received this message:

    ERROR: There is not sufficient space to move / home directory to /root

    Instead I've begun using this:

    # mkdir /root
    # usermod -d /root root

    ReplyDelete
  2. Rob is correct; the -m switch is to "Move" the home directory, not "Make" it. Otherwise very helpful, thanks.

    ReplyDelete