How do I create a new user in Debian without home directory?
Asked
Active
Viewed 3.2k times
5 Answers
9
Not really sure if you can create a user which doesn't have a home directory specified. That being said, the specified home directory doesn't have to exists. You can call the adduser with the option --no-create-home.
adduser --no-create-home foo
(adduser is usually the preferred higher level tool if called interactively.)

andol
- 6,938
- 29
- 43
2
According to the man page of useradd(8)
you either want to add the parameter -M
to your useradd
call or you want to set CREATE_HOME=no
in /etc/default/useradd
.
-M Do no create the user's home directory, even if the system wide setting from /etc/login.defs (CREATE_HOME) is set to yes.

joschi
- 21,387
- 3
- 47
- 50
-
1-1, the very first paragraph of useradd(8) tells you, not to use it, but adduser. – May 06 '10 at 07:30
1
$ useradd joe $useradd -m joe does the opposite
edit : rtfm ;) http://linux.die.net/man/8/useradd

Razique
- 2,276
- 1
- 19
- 23
-
-
-
Depending on the settings for `$CREATE_HOME` in `/etc/default/useradd` the second command certainly does not do the opposite… – joschi May 06 '10 at 07:12
-
ain't you confusing -m and -M (in capitals) ? -m, --create-home The user's home directory will be created if it does not exist. The files contained in SKEL_DIR will be copied to the home directory if the -k option is used, otherwise the files contained in /etc/skel will be used instead. Any directories contained in SKEL_DIR or /etc/skel will be created in the user's home directory as well. The -k option is only valid in conjunction with the -m option. The default is to not create the directory and to not copy any files. – Razique May 06 '10 at 07:21
-
-
1-1, the very first paragraph of useradd(8) tells you, not to use it, but adduser. – May 06 '10 at 07:29
-
-1
As root on a Linux machine
[root@stapp01 ~]# cat /etc/passwd | grep anita
[root@stapp01 ~]# useradd -M anita
[root@stapp01 ~]# id anita
uid=1002(anita) gid=1002(anita) groups=1002(anita)
[root@stapp01 ~]# cat /etc/passwd | grep anita
anita:x:1002:1002::/home/anita:/bin/bash
[root@stapp01 ~]#
[root@stapp01 ~]# ll /home/
total 8
drwx------ 2 ansible ansible 4096 Oct 15 2019 ansible
drwx------ 2 tony tony 4096 Jan 25 2020 tony
[root@stapp01 ~]#
Parameter of command useradd
:
-M
The user home directory will not be created, even if the system wide settings from /etc/login.defs is to create home dirs.

ppuschmann
- 610
- 1
- 6
- 16

pirmatov
- 11