Files
code-snippets/docs/linux/add-user.md
T
LiamPietralla d8961b6292
Build, Test & Publish / Build (push) Successful in 59s
Build, Test & Publish / Build and Publish Container Image (push) Failing after 23s
Build, Test & Publish / Deploy to Infrastructure (push) Has been skipped
add linux
2026-05-08 12:56:30 +10:00

824 B

Add User to Linux

To add a user to a Linux system use the add user command:

sudo adduser username

To enable sudo privileges for the user, add the user to the sudo group:

sudo usermod -aG sudo username

To setup a ssh key for the user, switch to the user and create the .ssh directory:

sudo su - username
mkdir ~/.ssh
chmod 700 ~/.ssh

Then create the authorized_keys file and add the public key:

touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
vim ~/.ssh/authorized_keys

Paste the public key into the file and save it. The user should now be able to log in using the ssh key.

To enable sudo without a password, edit the sudoers file:

sudo visudo

Add the following line to the end of the file:

username ALL=(ALL) NOPASSWD:ALL