HostOnNet Blog

useradd – create linux user

To create a user, run

useradd -d /home/USERNAME -s /bin/bash USERNAME

-d specify the home directory of the user.

-s specify the shell used by user.

To create a linux user with no SSH/terminal access, run

useradd -s /sbin/nologin USERNAME

Create a User to run system service

Normally system services are run by users with UID/GID below 500. The -r flag of useradd will create user for system service. For example

groupadd -r prometheus
useradd -r -g prometheus -s /sbin/nologin -d /usr/hostonnet/prometheus/ -c "prometheus Daemons" prometheus

Set Password for a user


Posted in Linux