What does the -m option do in the 'useradd' command?

QuestionsQuestions8 SkillsProUser Account ManagementAug, 01 2025
0451

The -m option in the useradd command is used to create a home directory for the new user. Here’s a detailed explanation of what this option does:

Functionality of the -m Option

  1. Home Directory Creation:

    • When you use the -m option, the useradd command automatically creates a home directory for the new user. The default location for this directory is typically /home/username, where username is the name of the user being created.
  2. Directory Structure:

    • The home directory is set up with the appropriate ownership and permissions. By default, it is owned by the new user and has permissions set to 700 (rwx------), meaning only the user has read, write, and execute permissions.
  3. Default Files:

    • Depending on the system configuration, the home directory may also be populated with default configuration files (like .bashrc, .profile, etc.) from a skeleton directory, usually located at /etc/skel. This provides the user with a basic setup for their environment.

Example Usage

Here’s how you would use the -m option when creating a new user:

sudo useradd -m joker

In this example, a new user named joker will be created, and a home directory at /home/joker will be created for them.

Summary

The -m option is essential for ensuring that new users have a dedicated space to store their personal files and settings, making it a common practice when adding new users to a Linux system. If you have any more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!