How can i change the username root … i am new here
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
root is the default user on most Linux OS’s, and you would’t want to change or remove that user as the OS relies on that user existing. Changing the username by altering it, or removing it completely would render the OS unusable and you’d have to boot from recovery or start from scratch.
What you’d want to do, ideally, is create a sudo user. You’d start by creating a basic user first:
… and then you’d add that user to the sudo group.
usermod -aG sudo myuser
The above command adds myuser to the sudo group, but doesn’t change the primary group.
From there, you’d want to set a password on the user (if you’re not using SSH Keys):
You’ll be prompted to type in a password and then confirm it by typing it in again. Once the password is setup, you’ll want to try and login with the new sudo user and make sure you can escalate. So I’d run something that requires root.
sudo apt-get update
You’ll be prompted to enter in your password. If it succeeds, you can then lock the root user account which will prevent it from being used (you won’t be able to login with it anymore, until you unlock it).
As the sudo user, run:
sudo passwd -dl root
That’ll remove the root users password and then lock it.
You don’t. Add another (sudo) user if you need to.
Join 1M+ other developers and: