By default the user working directory creating in /home for example if I have created a new user the name of “testuser” the user working directory would be /home/testuser
# useradd testuser
# cd /home/testuser
# cd /home/testuser
Do you require to change the home directory of a user, open the useradd configure file and update HOME path
# vi /etc/default/useradd
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
HOME=/home change to HOME=/opt
Create a new user : playboy
root@host [~]# cd /opt/playboy/
root@host [/opt/testuser]# ls -al
total 20
drwx------ 2 32014 32015 4096 Jun 14 15:49 ./
drwxr-xr-x 12 root root 4096 Jun 14 15:49 ../
-rw-r--r-- 1 32014 32015 18 Jul 18 2013 .bash_logout
-rw-r--r-- 1 32014 32015 176 Jul 18 2013 .bash_profile
-rw-r--r-- 1 32014 32015 124 Jul 18 2013 .bashrc
root@host [~]# finger playboy
Login: testuser Name:
Directory: /opt/playboy Shell: /bin/bash
Never logged in.
No mail.
No Plan.
root@host [/opt/testuser]# ls -al
total 20
drwx------ 2 32014 32015 4096 Jun 14 15:49 ./
drwxr-xr-x 12 root root 4096 Jun 14 15:49 ../
-rw-r--r-- 1 32014 32015 18 Jul 18 2013 .bash_logout
-rw-r--r-- 1 32014 32015 176 Jul 18 2013 .bash_profile
-rw-r--r-- 1 32014 32015 124 Jul 18 2013 .bashrc
root@host [~]# finger playboy
Login: testuser Name:
Directory: /opt/playboy Shell: /bin/bash
Never logged in.
No mail.
No Plan.
Would you like to modify the user home directory /opt to /home path ,
Run following command to modify:
# usermod -d /home/playboy -m playboy
Now open /etc/passwd file and search for playbox user,
# vi /etc/passwd
Playboy:x:501:501:playboy:/home/playboy:/bin/bash
Playboy:x:501:501:playboy:/home/playboy:/bin/bash
-d Current home directory will be moved to the new home directory
-m Move the user home directory to the new location
Comments (0)