how to change username and password on kali linux

How To Change Username & Password in Kali Linux

Changing your password is a good practice, and the process is fairly straightforward. Changing your username might be a good idea in some cases (especially if you use the default one), but it is much less simple because everything is based on it (folder names, permissions, etc.). Let’s see how to do it quickly and safely.

On Kali Linux, the password can be changed either through the user settings (with a GUI) or directly from the command line. Changing the username, however, requires switching to the administrator account and renaming the user.

I’ll start with the password update (this will be quick), and then explain in details how to change the username if you really need to do that.

Master Linux Commands
Your essential Linux handbook
Want to level up your Linux skills? Here is the perfect solution to become efficient on Linux. 20% off today!

Download now

How to change the user password on Kali Linux

There are two ways to update your password on Kali Linux:

  • Using the “Users and groups” tool available via the graphic user interface (GUI)
  • Doing it in a terminal, with the “passwd” command

But let’s discuss first how to choose a strong password for your system.

How to pick a strong password

Most people think that a strong password is something impossible to remember, with upper and lower case letters, special characters and random numbers.

It’s not necessarily true.

In fact, length is the most important factor when picking a new password. For example, “p@ssw0rd” will be way quicker to crack than “thisismylongsecretpassword“. And obviously, the latter is easier to remember, so you won’t need to note it near your computer or worse, in a file.

Become a Cyber Security Expert!:
Enroll in the Complete Cyber Security Course now, and master online safety.
Learn to defeat hackers, protect privacy, and stay anonymous with over 50 hours of on-demand video.

Here is my favorite tool to generate a strong password, that can also be easy to remember. It combines several words to make it easy for you. You can add numbers and special characters if you like, but something longer than 15 letters is already pretty solid in most cases.

A good practice to keep in mind is that it is important to change your password regularly. That way, even if a hacker finds a way to get your password (and decrypt it), they won’t be able to use it if you’ve updated it since the breach.

Related articles on this website:

Method 1: Update your password via the GUI

The first way to change the user password on Kali Linux is to open the users settings via the GUI.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!

You’ll find this window by opening the Main menu, go under Settings and click on “Users and groups”:

In there, click on “Change…” next to the password line, and you’ll get a popup like that:

Enter the current password and enter the new password twice. You can either choose your own password or use the built-in password generator to get a strong suggestion (but harder to remember than the tool I mentioned in the previous part).

Method 2: Update your password in command lines

It’s also possible to update the password for the current user from a terminal (directly via the GUI, or connected via SSH). To do it, enter this command:
passwd

As with the previous method, you will be prompted for the current password and then asked to type the new password twice.

Either way, changing the user password on Kali Linux is not complicated, but changing the user name is a bit more challenging. Let’s see how to do it.

How to change the username on Kali Linux

Here are the main steps to change the default username on Kali Linux:

  • Make sure you have a full backup of your system, in case something goes wrong.
  • Enable the administrator session (root) and log in with it.
  • Use the “usermod” command to change the username.

Never done this? Don’t worry, I’ll explain everything in details now.

Preparations and Cautions

While this procedure is safe in theory, you must understand that everything is based on the user name. The home directory is named after it, the permissions are set for it, so you might experience some weird things if something goes wrong or you miss a step.

You shouldn’t lose any files because we’re going to enable the administrator account, which has access to everything. However, just in case, it is recommended that you make a full backup of your system, and especially your important documents, before following the next steps.

Just make sure you can get back to the previous state, or at least not lose anything in the process.

Enable root session

Root is the administrator account in Kali Linux. It’s disabled by default on new installations, so the first step is to enable it.

We can’t change the username from the same user session, we need to use a different one. Unless you have created another user with sudo access, the easiest way to do this is to enable root.

To do this, the only thing to do is to create a password for it, with:
sudo passwd

Yes, it’s the same command as previously, but by adding sudo it changes the password for the administrator account, not for the current user. If it’s the first time doing this, it won’t ask the current password (there is none by default).

Log out

Once the root user is active and has a password set, we can close the session for the current user and move on.

Make sure that the user session you want to rename doesn’t have an open session. Close the GUI session, but also make sure that no other process or remote sessions are active.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!

If it’s possible in your situation, a reboot is probably the fastest way to kill all running processes (as long as auto-login is not enabled, but I’m guessing that’s not the case if you’re reading this).

Log in as root

Now, you can log in as root:

  • If you have a desktop environment, type “root” in the username field, and the password you just set.
  • You can also use the command line if you prefer (CTRL+ALT+F1) or don’t have a GUI.

Either way, we’ll use a command line to rename the user, so we just need a command prompt with the root user.

Rename the user

Once logged in in a terminal with the administrator account, the username can be renamed with:
usermod -l <new_user> <old_user>

Hide your IP address and location with a free VPN:
Try it for free now, with advanced security features.
2900+ servers in 65 countries. It's free. Forever.

So, in my case, to rename “pat” to “patrick”:
usermod -l patrick pat

While we are there, it’s also a good idea to rename the home folder to match the new username:
usermod -m -d /home/<new_user> <new_user>
For example:
usermod -m d /home/patrick patrick

That’s it, you can now quit the root session, and move to the tests part:
exit

Tests

Try to log in with your new username. It should work without needing to reboot.
The password for this new user will be the same as for the old user.

From there, you might want to revert previous changes, like enabling the auto-login and disabling the SSH access for root.

You can also disable the root user completely with:
sudo passwd -l root
It’s better to keep it disabled when you don’t need it, especially now that you no longer use the default user name for the main user.

If needed: Fix XFCE display

I got an issue with XFCE during my test, as XFCE doesn’t update the home directory when doing this. So I didn’t have the full interface once logged in.

Unable to launch xfwm4: failed to change to directory /home/pat

If you rename the home directory, you must follow these steps to reset the XFCE configuration:

  • Once logged in with the new username, you’ll only get access to a terminal (no menus)
  • Type these two commands from your home directory:
    mv ~/.config/xfce4 ~/.config/xfce4.backup
    mv ~/.cache/sessions ~/.cache/sessions.backup
  • Restart the computer:
    sudo reboot
  • Log in again, and it should work properly.

I hope this article helped you to change your user name and password, which are good practice when you work with security tools like on Kali Linux.

I have plenty of tutorials about Kali Linux on this website, so feel free to check them out, here are a few examples:

Whenever you’re ready for more security, here are things you should think about:

- Break free from Gmail: You should be able to choose what happens to your data. With Proton, only you can read your emails. Get private email.

- Protect yourself online: Use a high-speed Swiss VPN that safeguards your privacy. Open-source, no activity logs. Get Proton VPN risk-free.

- Master Linux commands: A sure method to learn (and remember) Linux commands. Useful ones only, one at a time, with clear explanations. Download the e-book.

Similar Posts