Changing the default home directory
Jump to navigation
Jump to search
Change Default User Home Directory While Adding A New User
By default, when we create or add users to Linux System, user’s default home directory is created to /home. To change default directory to /opt/, we need to change few settings as mentioned below:
As the root user open /etc/default/useradd using your favorite editor.
[root@workbox dwmoar]# nano /etc/default/useradd
The default home directory defined by HOME variable, find line that read as follows: HOME=/home
useradd defaults file GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel
and change it to read HOME=/opt Save and close the file.
Now you can add a user, using the useradd command in a console window as the root user:
useradd username passwd -d userpassword
Verify user information: NOTE: You will have to install the finger program through the Synaptic package manager.
finger username
Output: Login: username Name: username userpassword Directory: /opt/username Shell: /bin/bash Never logged in. No mail. No Plan.