The explanation on the title of this article is actually happened upon creating a new user using ‘useradd’ in an operating system which in this case, it is an Ubuntu 16.04.4 LTS. But after several attempt, although the user specified as the parameter of the command ‘useradd’ has been successfully created, it didn’t create the associated home folder. So, the following are the situation happened :
user@hostname:/home$ useradd myuser user@hostname:/home$ ls -al total 32 drwxr-xr-x 5 root root 4096 May 2 10:18 . drwxr-xr-x 24 root root 4096 May 23 06:12 .. drwxr-xr-x 2 guest guest 4096 May 2 10:18 guest drwxr-xr-x 71 user user 4096 May 24 06:07 user drwx------ 2 root root 16384 May 19 09:44 lost+found
Based on the output above, there is no additional folder created name ‘myuser’ as the home folder of user named ‘myuser’. The reason actually because there is another command which is more suitable than ‘useradd’ none other than ‘adduser’. Based on the explanation given is the ‘useradd’ command or program has been deprecated where furthermore it has been replaced with another command or program named ‘adduser’. From the manual page of useradd, in the description part, it can be shown as follows :
useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead.
So, in order to create user with its associated home folder, use ‘adduser’ which is shown as follows :
root@hostname:~# adduser admin Adding user `admin' ... Adding new group `admin' (1002) ... Adding new user `admin' (1002) with group `admin' ... Creating home directory `/home/admin' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: Sorry, passwords do not match passwd: Authentication token manipulation error passwd: password unchanged Try again? [y/N] y Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for darkhamster 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 root@hostname:~#
Actually, the user itself has been successfully created. It can be checked in the /etc/passwd as shown below :
root@hostname:/home# cat /etc/passwd | grep admin ... admin:x:1003:1003::/home/admin: ... root@hostname:/home#