skip to content
Hiiruki's lab
Table of Contents

Intro

I was using the Kali Linux virtual machine edition, specifically the pre-built version for VMware and VirtualBox. In this version, the default username is “kali” since it’s pre-configured, and we don’t get to choose the username during installation. I found the default “kali” username a bit boring, so I wanted to change it to something I preferred. If you feel the same way, this guide is for you. Let’s get started!

Steps

1. Change to the root user

Terminal window
$ sudo -i

after that we can change the root password by typing:

Terminal window
$ passwd

type your new root password and confirm it.

2. Logout and switch to root user or restart

You can choose Log out, Switch user, or restart. I choose to restart because it’s faster and it’s a virtual machine. For server or production environment, you can choose to log out or switch user.

Use the root credentials that we already set in step 1.

3. Change the username as well as the home directory and the group

Make sure you are logged in as root user.

Then change the username using the following command:

Terminal window
$ sudo usermod -l new_username -d /home/new_username -m old_username

Example:

Explanation:

  • -l is to change the login name
  • -d is to change the home directory
  • -m is to move the content of the old home directory to the new home directory

Change the group name using the following command:

Terminal window
$ groupmod -n new_username old_username

Example:

Explanation:

  • -n is to change the name of the group

Create symbolic link for the old home directory to the new home directory

Type the following command:

Terminal window
$ ln -s /home/new_username /home/old_username

Example:

Explanation:

  • -s is to create a symbolic link

(Optional) Change the user finger information (user database information). In this case I just want to change the full name.

Terminal window
$ chfn -f "New Full Name" new_username

Example:

Explanation:

  • -f is to change the full name

4. Logout and switch to the new username or restart

Input your new username and the old password, which is kali in my case.

Check the home directory and the group name. Make sure they are correct.

My data is still there as expected.

Then change the password for the new username.

Terminal window
$ sudo passwd new_username

Type your new password and confirm it.

Summary

Everything is done. You have successfully changed the username as well as the home directory and the group. You have also created a symbolic link for the old home directory to the new home directory. You have also changed the user finger information and the password. Congratulations!

References