LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 01-19-2020, 10:21 PM   #1
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Debian useradd and CREATE_HOME


Trying to get familiar with Debian 10. Here is my first hickup:
Code:
root@debian:~# grep CREATE /etc/login.defs
CREATE_HOME=yes
root@debian:~# useradd user123
root@debian:~# ls /home
student
root@debian:~#
According to the man pages for login.defs and useradd, CREATE_HOME should make useradd create the home directory. What am I missing?
 
Old 01-19-2020, 11:04 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

not sure. However on Debian you should probably use adduser, not useradd. From the useradd man page:

Code:
DESCRIPTION
       useradd is a low level utility for adding users. On 
       Debian, administrators should usually use adduser(8)
       instead.
Evo2.
 
1 members found this post helpful.
Old 01-20-2020, 12:21 AM   #3
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by berndbausch View Post
According to the man pages for login.defs and useradd, CREATE_HOME should make useradd create the home directory. What am I missing?
That "CREATE_HOME" does not apply to system users:
Code:
   -m, --create-home
           Create the user's home directory if it does not exist. The files and
           directories contained in the skeleton directory (which can be defined with the
           -k option) will be copied to the home directory.

           By default, if this option is not specified and CREATE_HOME is not enabled, no
           home directories are created.
(and further on)
    CREATE_HOME (boolean)
           Indicate if a home directory should be created by default for new users.

           This setting does not apply to system users, and can be overridden on the
           command line.
So best use the option -m to create home dirs (and make sure your /etc/default/useradd file has been created and filled with the right values for all you do not give on the commandline). For instance
Code:
HOME=/home
makes sure that that home dir will be created below /home, which otherwise is NOT the default, it is created as a subdir to the current one.
 
Old 01-20-2020, 12:49 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Original Poster
Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ehartman View Post
That "CREATE_HOME" does not apply to system users:
I know, but this is not a system user. The values in the defaults file have their own defaults, such as HOME's default is /home:
Code:
man useradd
...
-b, --base-dir BASE_DIR
...
   If this option is not specified, useradd will use the base
   directory specified by the HOME variable in /etc/default/useradd,
   or /home by default.

Last edited by berndbausch; 01-20-2020 at 12:57 AM.
 
Old 01-20-2020, 12:57 AM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Original Poster
Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by evo2 View Post
not sure. However on Debian you should probably use adduser, not useradd.
Good point, thanks.
 
Old 01-20-2020, 01:15 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Original Poster
Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Ugh. Attention to detail, as my CV says.

Instead of CREATE_HOME=yes, just write "CREATE_HOME yes". Without the equals sign.

To my defense, /etc/default/useradd is indeed a shell script. Why login.defs is not - well, I guess historic reasons.

Last edited by berndbausch; 01-20-2020 at 01:17 AM.
 
Old 01-20-2020, 07:56 AM   #7
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by evo2 View Post
However on Debian you should probably use adduser, not useradd.
adduser is a script over useradd, it asks for all of the values for the pasword file and then issues an useradd command with all values given, so it doesn't rely on /etc/default/useradd nor /etc/login.defs, everything is given through useradd command line options (except the password, for which passwd is called directly).
Quote:
$ file /usr/sbin/adduser
/usr/sbin/adduser: Bourne-Again shell script, ASCII text executable
(in Slackware).
 
Old 01-20-2020, 08:45 PM   #8
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
It's also a script that calls useradd in Debian but it's in written in perl and gets the config from /etc/adduser.conf

Evo2.

Quote:
Originally Posted by ehartman View Post
adduser is a script over useradd, it asks for all of the values for the pasword file and then issues an useradd command with all values given, so it doesn't rely on /etc/default/useradd nor /etc/login.defs, everything is given through useradd command line options (except the password, for which passwd is called directly).

(in Slackware).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to create a user in Ubuntu/Debian: ‘useradd’ command usage, a beginner’s guide LXer Syndicated Linux News 0 11-05-2019 01:30 AM
Useradd - Cannot locate /etc/default/useradd in Solaris Paean Solaris / OpenSolaris 4 12-09-2005 01:36 AM
useradd and modifying style.css and index.html to add new user's name kelticfury Linux - General 2 05-22-2004 09:21 AM
Groupadd and useradd for RH 8.0 ??? edhan Linux - Newbie 12 10-07-2003 11:08 PM
/etc/shadow and useradd -p usermod -p granny Linux - Security 3 08-29-2003 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 09:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration