Change default root/users for security

I am new to linux and my profession is not computer sciences, but i am learning.
I do understand a bit about user accounts in Linux: root and users etc.
I would like to change users names for securing login. So how do i do it correctly? Found some information but non is complete. What i would like to do:

  1. delete or rename or disable root
  2. delete or rename dietpi
  3. or create a new user that can act as root


You cannot and must not remove the root user as it is essential part of any Linux system. And on DietPi you should not remove the dietpi user, as it is used by some software installs, but we’re going to remove it in a future release. But what you can do is lock those (disable their password so that it isn’t possible to login):

usermod -L root
usermod -L dietpi

But before doing so, create an own user account that you want to use for login, like:

useradd -mk /etc/skel -s /bin/bash eglider86
passwd eglider86

This creates a user named “eglider86” with its home directory /home/eglider86, including the default files added from /etc/skel and bash as login shell. The second command is to assign a password. Without a root user account, you may also allow this new user to run commands with root privileges via sudo:

usermod -aG sudo eglider86
1 Like

Thank you so much. Real education here!
Yes i have realized the dietpi account is needed, since after deleting it i was not able to add softwares…
Ok. I follow your points.
Thanks again

if you like to keep local access as root user (backup/fall back/emergency access), you could simply disable SSH login for user root.

i have added new user to sudo, but the system keeps asking for user password that did not happen with dietpi user

The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed.

Thank you!

You can disable the password prompt as well:

echo 'eglider86 ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/eglider86