CATEGORIES

TAGS

SSL

PostgreSQL

cPanel

email

Error

WHM

Linux

Bash

Debian

Ubuntu

How to create new user and group in Linux

3rd April
Linux
How to create new user and group in Linux

Creating new users and groups in Linux systems is very important because you can give permissions allow users to changing your files. You should understand how you need to create users and groups and what permissions you can give them.

Creating users:


To create new users in Linux is used the command “useradd”. The basic command is like this:

Copied!

sudo useradd usernamenedded



if you want create some user which will have home directory and can log in use this command:

Copied!

sudo useradd jack



but if you want to create user without home directory and who can’t log in execute this command:

Copied!

sudo useradd –m jack



it is important too to create password for each user. To set new password run this command:

Copied!

sudo passwd jack



the system will ask you the new password then you need rewrite it and press “enter” to set password. But if you want to create new user and set for them new password in one stem you are allowed use this command:

Copied!

sudo useradd –m jack –p userPassword



where “userPassword” is the password for user.

Creating groups:


To create new groups you should use the command “groupadd”. Let’s create some group with name “newgroup” and add there the new user which we have created by name “jack”.

Copied!

sudo groupadd newgroup



now we can add the new user into this group. To do this you need to use the command “usermod” like this:

Copied!

sudo usermod –a –G newgroup jack



INFO: “-a” is using for tell “usermod” that we are appending the name, and “-G” tell “usermod” that we append the name to the group.



To know what members have our group you can run this command:

Copied!

grep newgroup /etc/group



that is all!!!


SUBSCRIBE by email and never miss a post!