To change the default home directory for a new user in Linux, you can use the useradd
command with the -d
option.
Here's an example of how to use the useradd
command to create a new user with a custom home directory:
useradd -d /path/to/custom/home/directory username
This will create a new user with the username username
and the home directory /path/to/custom/home/directory
.
You can also use the -m
option to create the home directory if it doesn't already exist. For example:
useradd -d /path/to/custom/home/directory -m username
This will create the home directory if it doesn't already exist and set it as the home directory for the username
user.