Browse guides

Create an administrator user

Avoid daily work as root by using a named account with controlled sudo privileges.

Beginner7 min readUpdated
On this page

Create the account

Sign in as root, then create a named account. Replace β€œalex” with your own username.

Terminal β€” as root
adduser alex
usermod -aG sudo alex

Authorize your SSH key

From your local computer, copy your public key to the new account. ssh-copy-id creates the correct permissions automatically.

Terminal β€” local computer
ssh-copy-id [email protected]

Test the new access

Open a second terminal window and test the account before closing your current root session.

Terminal
ssh [email protected]
sudo whoami

Keep the root session open

Only close it after sudo whoami returns β€œroot”. This gives you a recovery path.