Site icon Narayana Tutorial

Create user without login – Create System User in Linux

delete files in linux

delete files in linux

Create user without login – Create System User in Linux

As a Linux framework head, there are times when you may have to make a client who doesn’t can sign in. When might that kind of client be important? Say, for example, you need to make a client for an application to work appropriately, however, you don’t need that client to either have a home registry or the capacity to sign in.

There are various approaches to deal with this errand, however, I need to show you the right method to do it.

Pre-Requisites

The existing user who going to creating the user should be having sudo privileges.

The most effective methods to make the Linux account

 

Method 1

Keep in mind, we’re making a Linux account that can’t sign in. As such, this is a framework account. Suppose, the record you need to make is called testuser1. There are two legitimate approaches to make this framework account.

The main technique expects you to physically design the shell, with the end goal that the client can’t sign in. Sign in to your Linux worker or work area and issue the order:

 

The below command creates the user with a home directory and without shell(without login)

sudo adduser testuser1 --shell=/bin/false

 

The below command creates the user without a home directory and without shell(without login)

sudo adduser testuser1 --shell=/bin/false --no-create-home

 

Method 2

sudo adduser testuser1  --system

The above command will create the user account without a password and without shell so the user can’t log in. However, the above command also creates a home directory.

 

Method 3

If we do not want a home directory then we can use the following command to create the user without a home directory, without login, and without a shell

sudo adduser testuser1 --system --no-create-home

 

Method 4

Generally, after creating a system user in the above, we can add the system user into the group.

By using the below command, we can add the system user into the group. Here we are adding testuser1 system user into the group i.e. testGroup

sudo usermod -aG testGroup testuser1

 

The below command creates the user and adds it into the group and the group name is the same as the username.

sudo adduser testuser1 --system --no-create-home --group

 

Switch User to above-created system user

Once you logged in to the system by using your credentials, then we can switch it to system user by using the following command.

sudo su testuser1

Delete above-created system user

By using the following command, we can delete the system user which is created earlier.

sudo userdel testuser1 -r