Ubuntu normally blocks direct root logins and leaves the root password unset. If you need to sign in as root—for example, on a system you control and where the regular account is no longer wanted—start by giving root a password.

Set the root password

Run the following and enter the new password twice when prompted:

sudo passwd root

Allow root over SSH

Open the SSH daemon configuration:

sudo vi /etc/ssh/sshd_config

Find PermitRootLogin and change its value to:

PermitRootLogin yes

Restart SSH so the new setting takes effect:

sudo systemctl restart sshd

Log back in as root and confirm that root access works before you remove the regular account. Testing first matters: if root login fails after you have deleted the other user, you can lock yourself out.

Remove a regular user

To delete the user together with their home directory, use:

userdel -r username

If you only want to remove the account and leave the user's files in place, run:

userdel username

To list accounts that can log in with a shell, check for bash entries:

grep bash /etc/passwd

For a full view of every account on the system, including built-in service users:

cat /etc/passwd

Once root login is confirmed and the regular account is gone, the system can be managed through root as intended.