I want to create a new user to run a service on the system but don't want to have /home
and other configuration files for it. Like there is a user for postgres but it doesn't have any /home
directory.
I want to create a new user to run a service on the system but don't want to have /home
and other configuration files for it. Like there is a user for postgres but it doesn't have any /home
directory.
By default the command useradd doesn't create home directories, but for a daemon I recommend you to use the system option and change the shell to a non-existent one so no one can login with said account (in ssh for example):
You can see all the options with
man useradd
andman groupadd
if you want to create a group for the user too.Try
adduser --system --no-create-home USERNAME
or simply have a look at theman adduser
which claims to be a "friendlier front end to the low level tools like useradd...".I needed something similar - a new user without login privileges and tied to a system service. However, the answer by Clausi creates a user with the primary group as 'nogroup', which wasn't really desirable.
adduser --system --no-create-home --group USERNAME
creates a system group with the same name as the user and associates it with the user as the primary group. This can then be verified by using thegroups USERNAME
or theid USERNAME
command.To add user without home directory the commands are,
or
or
or
try this command:
sudo useradd vivek
This will create a user without creating your home folder at
/home/vivek
Creating a User without Password with Home directory:
User & Group
Create the desired Group and User with Home-Dir.
Permissions
Add your primary user to the new group (Optional)
To see all the groups, use:
$ id
,$ groups
. login to a user:$ sudo su - <USER>
. Re-login or Reset-PC is required.Remove User and Group