To create a user, run
useradd -m -s /bin/bash USERNAME
-m = create home directory.
-s = specify location of shell.
To create a user with custom home directory, use
useradd -d /var/www -s /bin/bash USERNAME
Create User with Specific User id
Create the user “serverok” with uid 4223, run
useradd -u 4223 serverok
Create User to Run System Service
-r option select gid/uid for running system service.
groupadd -r prometheus useradd -r -g prometheus -s /sbin/nologin -d /usr/hostonnet/prometheus/ -c "prometheus Daemons" prometheus
Related commands
Create, delete, and modify local user accounts
Add: useradd Delete: userdel Modify: usermod
Create, delete and modify local groups and group memberships
Add: groupadd Delete: groupdel Modify: groupmod
To add a user to sudo/wheel group, see usermod
Leave a Reply