How to add a home directory for existing user

In this article let’s discuss about How to add a home directory for existing user. Let’s go through the following methods without any delay.

Method 1:

first edit the /etc/passwd file with root account 
#chnaging part : find your user username and add /home before it then do the following steps

#replace hamsof with user username
sudo -i                            #to get root privileges
mkdir /home/hamsof                #to create the directory /home/hamsof
cp -rT /etc/skel /home/hamsof         #to populate /home/linda with default files and folders
chown -R hamsof:hamsof /home/  #to change the owner of /home/linda to user linda


Hope the above solution works.

Realted Posts : Grep nth line