-d: Specify the home directory for the user. Linux Commands – Overview with Examples and FAQs

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
Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?