Introduction
The Linux command -d is used to specify the home directory for a user. This command is used to set the home directory for a user when they log in to the system. It is important to set the home directory for a user as it is the directory where the user’s personal files and settings are stored. The -d command is used to set the home directory for a user and can be used in conjunction with other commands to customize the user’s environment.
Examples
Example:
To set the home directory for the user ‘john’ to ‘/home/john’, run the following command:
$ sudo usermod -d /home/john john
The -d
option is used to specify the home directory for a user in Linux. This option is used when creating a new user account with the useradd
command. The syntax for this command is as follows:
useradd -d [home_directory] [username]
For example, to create a new user account with the username “john” and the home directory “/home/john”, the command would be:
useradd -d /home/john john
The -d
option can also be used with the usermod
command to change the home directory of an existing user. The syntax for this command is as follows:
usermod -d [home_directory] [username]
For example, to change the home directory of the user “john” to “/home/john2”, the command would be:
usermod -d /home/john2 john