How to Add a Sudo User to Linux

In this guide we'll walk through the steps needed to add a sudo user to a Linux server.

See authorized keys for an account

$ sudo vim /home/<username>/.ssh/authorized_keys 

See all users

cat /etc/passwd

Manual for useradd

$ man useradd

Many for adduser

$ man adduser

Command to add new user

$ sudo adduser <user name>

Command to delete user

$ sudo deluser
Enter a user name to remove: <user name>

Switch into user account

$ sudo su <user name>

View ID

$ id

After changing into user account, create ssh/authorized key file

$ mkdir .ssh
$ vim .ssh/authorized_keys

Switch to previous account

ctrl + d

View sudoers

$ sudo cat /etc/sudoers

Add user to list of sudoers

sudo usermod -G sudo smt116

See full list of group members

$ cat /etc/group

Jordan Hudgens

Jordan Hudgens

I've been a software engineer for the past decade and have traveled the world building applications and training individuals on a wide variety of topics.

View All Posts