• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to set -m option as default in useradd command in linux

July 27, 2013 by Sharad Chhetri Leave a Comment

How to set -m option as default in useradd command in linux

Using -m option with useradd command create the user’s home directory . In Debian and Ubuntu when we simply use useradd command without any option bydefault it do not create user’s home directory in /home whereas in CentOS and Red Hat when you use useradd command without any option it creates the user’s home directory in /home.

So here is the question, How can we set the useradd command so that we do not have to use -m option to create user’s home directory in Debian or Ubuntu ?

So first lets see what happen when we do not use -m option with useradd command in Debian or Ubuntu.

Note: The below given command is reference of how you can create home directory by using useradd command.

useradd -m username

See in the screenshot carefully,when I use only useradd command without -m ,the user called joe home directory was not created in /home.
In second command I used “useradd -m” and user called john is created with its home directory in /home.

useradd -m
useradd -m

Follow The Given Below Steps, To Setup By-Default Create User’s Home Directory Option With Useradd Command

Step 1: Edit the line /etc/login.defs file and add the new line “CREATE_HOME yes” .And save and exit

# vi /etc/login.defs

CREATE_HOME  yes

Step 2: Now create a user without using any option and check in /home the user’s home directory will be created there.

Create User:

useradd username

Check User’s Home Directory

ls -l /home

Note:
Or Check in /etc/passwd what is the path of User’s home directory. It might be possible you are trying this practical in already running system and your system admin has set home directory in different path

cat /etc/passwd

or 

grep username /etc/passwd

For eg.

In below given eg. the john has /home/john as user’s home directory

root@tuxworld:~# grep john /etc/passwd
john:x:1011:1011::/home/john:/bin/sh
root@tuxworld:~#

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. setfacl: Option -m: Invalid argument near character 3
  2. Change mysql default port number in linux
  3. How to change mysql default data directory in Ubuntu
  4. Change the default port number of ssh server
  5. Change default editor of crontab in Ubuntu
  6. How to check default storage engine in MySQL server
  7. How to set default storage engine to MyISAM to InnoDB vice versa
  8. How To Find Absolute Full Path Of Command On Linux / Unix : which command
  9. type Command : Display Information About Command Type On Linux
  10. Linux Tac Command : Reverse Of cat Command Output

Filed Under: Linux Tagged With: useradd

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

semanage command not found in CentOS 6 and RHEL 6

Save iptables permanently on Ubuntu

Linux Tac Command : Reverse Of cat Command Output

sed command to display text between two strings or keywords

Yum command to download rpm file without installing in linux system

How to free pagecache, dentries and inodes from memory on linux

Search Keyword In Man Page Like We Search In vi / vim Editor

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

sed: -e expression #1, char 24: Invalid range end

configure: error: C++ compiler cannot create executables

Change the default port number of ssh server

WordPress host IP changed not able to open wp-admin and site page looks scattered

How to protect from port scanning and smurf attack in Linux Server by iptables

AttributeError: ‘WSGIRequest’ object has no attribute ‘session’ Django python web framework

Allow wget and yum in iptable

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy