Skip to main content

Create system user with custom home directory

To create a system user to run an app, you can use the useradd command.

Here is an example to create one with a custom home directory:

sudo useradd -d /opt/app -m -r -G docker,www-data docker-website

That docker-website user will have its home directory at /opt/app that will be created if it doesn't exists (if it does, you'll have to change its owner), will be a system user and will be in two groups, docker and www-data.