How to Add a New User in Linux
Introduction
Adding new users in Linux is essential for managing access and security on your server. This guide shows you how to create a new user, set a password, and assign permissions.
Step-by-step Guide
- Add a new user
- sudo adduser newusernamen
- (Replace
newusernamewith the desired username)
- (Replace
- sudo adduser newusernamen
- Set or change the user’s password
- sudo passwd newusername
- Add the user to the sudo group (optional, for admin rights)
- sudo usermod -aG sudo newusername
- Switch to the new user
- su - newusername
- (Optional) Set up SSH access for the new user
- Create the
.sshdirectory:n- mkdir -p /home/newusername/.ssh
- Set correct permissions:n
- chmod 700 /home/newusername/.ssh
- Add your public key to
authorized_keys:n- ano /home/newusername/.ssh/authorized_keys
- Set permissions:n
- chmod 600 /home/newusername/.ssh/authorized_keys
- chown -R newusername:newusername /home/newusername/.ssh
- Create the
Recommendations
- Only give sudo rights to trusted users.
- Use strong passwords or SSH keys for all users.
- Regularly review and remove unused user accounts.
Call To Action
eed a secure Linux VPS for your team? Check out our hosting plans! https://xernode.com/#pricing