Tuesday 21 March 2017

Linux : Create a new user for the machine

Creating a new user in linux is sometimes needed, when you want to share the user access with anyone. SSH to the machine over the newly created user is needed to provide the same to others.


As root, perform 
# useradd sampleuser

Change the password of the user
# passwd sampleuser
New Unix passwd: welcome1

Once a new user is added, it is automatically added to "/etc/passwd" file, if you want to change the default directory for the user , etc please edit that file as root
# cat /etc/hosts
sampleuser:x:54322:59969::/scratch/sampleuser:/bin/bash


Optionally, you can create a user with a specific home directory as 
# useradd -d /home/sampleuser    sampleuser

Add a group,
# groupadd samplegroup


Assign the user to the group
# usermod -g samplegroup   sampleuser

To list all groups,
# groups



Linux : Create a new user for the machine

Creating a new user in linux is sometimes needed, when you want to share the user access with anyone. SSH to the machine over the newly cre...