As part of the Solaris 11 Express Installation, you are required to create a named user, which is then the account you can log in as, no root for you. Anyways the problem here is that we had some machines which we subsequently wanted to change the name. Normally this would be simply handled by simple edits to the /etc/passwd and /etc/shadow. However when we made this change we found that boy were we wrong.
Rename the User in /etc/passwd and /etc/shadow
Just use a standard text editor to adjust the old names to reflect the new name.
# cat /etc/passwd | grep olduser olduser:x:101:10:olduser:/home/olduser:/bin/bash
After the update
# cat /etc/passwd | grep newuser newuser:x:101:10:newuser:/home/newuser:/bin/bash
# cat /etc/shadow | grep olduser olduser:$5$WSruhUri$4ewgas1zXKADOU4EUjrLthwg13HLAp6ag2xtoge9Y09:15233::::::
After the update
# cat /etc/shadow | grep newuser newuser:$5$WSruhUri$4ewgas1zXKADOU4EUjrLthwg13HLAp6ag2xtoge9Y09:15233::::::
Unmount the User’s Home Directory
We need to unmount the home directory, so that we can make changes to the zfs file system where the home directory lives.
# umount /export/home/olduser
Rename the ZFS File System
For consistencies sake we rename the ZFS file system of the user we are changing.
# zfs rename rpool/export/home/olduser rpool/export/home/newuser
Adjust the File System Mount Point
# zfs get mountpoint rpool/export/home/newuser NAME PROPERTY VALUE SOURCE rpool/export/home/newuser mountpoint /export/home/olduser local
# zfs set mountpoint=/export/home/newuser rpool/export/home/newuser
# zfs get mountpoint rpool/export/home/newuser NAME PROPERTY VALUE SOURCE rpool/export/home/newuser mountpoint /export/home/newuser local
Adjust the Autofs Rules
Using a standard text editor adjust the /etc/auto_home file to reflect the new user name in its rules
# cat /etc/auto_home | grep olduser olduser localhost:/export/home/&
After the update
# cat /etc/auto_home | grep newuser newuser localhost:/export/home/&
Reboot and Validate
Once all of these steps are complete, then you can give this machine a reboot, and make sure that everything is working perfectly. Once your reboot is complete if you see a prompt like this:
-bash-4.0$
Then you missed something and you need to re-walk through the steps, keep in mind that if you see this prompt more than likely you do not have any paths sourced, thus you will be unable to type commands as you are used to and will need to use the full path of the binaries, here are some examples.
- cat is /usr/gnu/bin/cat
- reboot is /usr/sbin/reboot
- zfs is /usr/sbin/zfs
But since you are extremely detail oriented, which is why you are here reading about how to properly rename a Solaris 11 user then you have already completed all of the above steps perfectly and have performed a successful reboot and validated that everything is working properly. You are now simply reading to ensure that I haven’t hidden a little tidbit of juicy goodness in the end of this article.
I have not.
Great blog. I just started using solaris 11 in a vm. From the looks of this article it seems that they want you to create a new user and move the data. Strange though. Anyway, I’m a bit surprised that solaris doesn’t want you logging in as root, I assume this is only in multi user mode, but I havn’t tried bringing it down to single and see if root works. I’m very impressed with 11, but they need to port some more software like google’s chrome to it. keep up the great posts!!!
One minor point in solaris 11:
If you create the user during installation, the user is added to /etc/user_attr to assume the root role.
You need to change/rename the user in this file, too. I had the luck that I had an root session open after deleting the old user…