Skip to content

Tutorials Servers Beginner1 min read

How to Create a Sudo User on Ubuntu

Stop working as root: create a new user on Ubuntu or Debian, grant sudo rights, copy your SSH key, and confirm administrative access works.

By ZSOLNET Editorial Team Updated

Key takeaways

  • Day-to-day work as root makes mistakes and break-ins more dangerous.
  • Members of the sudo group can run admin commands with their own password.
  • Copy your SSH key to the new user before disabling root login.

Create the user

Log in as root, then:

adduser deploy

Set a strong password and press Enter through the optional details.

Grant sudo rights

usermod -aG sudo deploy

Copy your SSH key

If you log in as root with a key, give the new user the same access:

rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy

Test

Open a new terminal:

ssh deploy@203.0.113.10
sudo whoami    # should print: root

Once this works, you can disable direct root login (PermitRootLogin no in /etc/ssh/sshd_config).

Frequently asked questions

What's the difference between su and sudo?

su switches to another user (often root) entirely. sudo runs a single command with elevated rights and logs it, which is safer and auditable.

Does this work on Debian?

Yes. On Debian you may need to install sudo first with apt install sudo.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

Open the ZSOLNET dashboard

No account yet?