How can i change the username root … i am new here
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!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.