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/bashAfter the update
cat /etc/passwd | grep newuser
newuser:x:101:10:newuser:/home/newuser:/bin/bashcat /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/olduserRename 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/newuserAdjust the File System Mount Point
zfs get mountpoint rpool/export/home/newuser
NAME PROPERTY VALUE SOURCE
rpool/export/home/newuser mountpoint /export/home/olduser localzfs set mountpoint=/export/home/newuser rpool/export/home/newuserzfs get mountpoint rpool/export/home/newuser
NAME PROPERTY VALUE SOURCE
rpool/export/home/newuser mountpoint /export/home/newuser localAdjust 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.