How to change the root's password in kali live USB with persistent data

Introduction

All of us want to be anonymous when we use kali linux.
Therefore we install kali on a live USB with or without persistent and encrypted
data. After that some of it’s primary data such as grub configurations need to be
editted but we couldn’t do that, becuase the bootable partition on the USB cannot
be changed.

To solve that problem, one way is to use ‘rufuse’ application on windows OS to
copy the image content on a USB and make it both changable and bootable. Doing
the following instructions will help you remove the annoying beep sound from
kali’s grub bootloader and such things.

The subject isn’t “How to make kali live USB editable” but it’s required to do
that before changing your root’s password in a kali live USB with persistent
data.

Let’s Do That

First of all open this file with a text editor:
“/lib/live/config/0031-root-password”

There is a line which contains sth like this “usermod -p ‘{password hash}’ root”.

You need to just put the generated hash of your password instead of
‘{password hash}’ part (with quotes and without curly braces).

How to get password hash

  • Open the terminal
  • Enter ‘passwd’ command (without quotes), and enter the new password
  • Open ‘/etc/shadow’ file with a text editor
  • Find the root’s password hash there.
    (That’s like: “root:{password hash}:{etc}”…)
  • Copy the first part (password hash)
  • Paste it in the intended line of “/lib/live/config/0031-root-password” which
    I described above.

That’s it

Remember that the “passwd” command makes a temperary password hash in
“shadow” file, which will not be persistent but will immediately
applied.
However, if you change the password in “0031-root-password” file, that will
be applied after next boot, but it’s persistent.