how to change the username root

How can i change the username root … i am new here

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


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:

useradd myuser

… 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):

passwd myuser

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.