Changing Username, Home Directory & Full Name


It is common now to acquire linux appliances with a preconfigured user account which you simply set a password for. Sometimes it is helpful to change your username for better integration with your network environment for example “ssh parallels@10.0.1.23” may become “ssh 10.0.1.23”, and transferring documents which use absolute pathnames in links to your home directory may be easier to transfer to your new system.

The following simple procedure can be used to update your user account details. In this example I’m using a Parallels pre-built virtual machine with the username “parallels” which I want to make my own.

  1. If a GUI is running switch out of it using something like ctrl + alt + F2
  2. login as the user “parallels” with the set password
  3. Enable the root account which is likely disabled with: sudo passwd root #then enter a root password
  4. Logout, then login as “root” with the password you’ve set
  5. Change the username with: usermod -l andrewread parallels
  6. Move the home directory with: usermod -d /home/andrewread -m andrewread
  7. You can verify this with: ls /home #to see the new home folder
  8. Change the full name with: chfn -f “Andrew Read” andrewread
  9. Depending on how the system is setup your user may have their own primary group, to update this do something like: groupmod -n andrewread parallels

You might want to disable the “root” account now and do all further system administration with the “sudo” command. This is optional:

  1. Logout of root then login with your new username which in this example is “andrewread”
  2. Clear the root password with: sudo passwd -d root #and enter your user account password when prompted
  3. Disable the “root” account with sudo usermod -L root

That’s all you need to do!