Easiest way to create a new user with home directory and default settings on Ubuntu

Abu Eesa
FusionQA
Published in
Dec 20, 2018

I was starting a new install of Jenkins and wanted to do it as a new jenkins user.

So first step I tried to create a new user on Ubuntu and tried via the command useradd jenkins .

Then when I tried to switch to the newly created jenkins user by sudo su — jenkins I got this error: No directory, logging in with HOME=/

It didn’t create the default directory and settings that I needed.

I deleted the jenkins user by sudo userdel jenkins and tried a MUCH easier approach:

By default on Ubuntu there is a Perl script called adduser , it’s basically a wrapper around useradd that helps to perform the operation in a wizard style. This will automatically create the default directory and other settings for the new user. Simply type:

adduser jenkins, the output should be something like:

Adding user `jenkins’ …
Adding new group `jenkins’ (1003) …
Adding new user `jenkins’ (1003) with group `jenkins’ …
Creating home directory `/home/jenkins’ …
Copying files from `/etc/skel’ …
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for jenkins
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

--

--