Debian: create a new user without home directory
Solution 1
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.)
Solution 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.
Solution 3
On Debian based systems typically the adduser
command is used to create new accounts instead of directly calling useradd
.
The adduser
option to skip creating a home directory is --no-create-home
.
Solution 4
$ useradd joe $useradd -m joe does the opposite
edit : rtfm ;) http://linux.die.net/man/8/useradd
Related videos on Youtube
user3848402
Updated on September 17, 2022Comments
-
user3848402 almost 2 years
How do I create a new user in Debian without home directory?
-
Andrii Y. about 14 yearsdoes the opposite? doesnt it just "make" the user?
-
Razique about 14 yearsuseradd -m creates the home dir (for instance /home/joe)
-
joschi about 14 yearsDepending on the settings for
$CREATE_HOME
in/etc/default/useradd
the second command certainly does not do the opposite… -
Razique about 14 yearsain'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 about 14 yearsplease stop down-rate without any explanation. thanks
-
user1711008 about 14 years-1, the very first paragraph of useradd(8) tells you, not to use it, but adduser.
-
QuintenVK about 14 years-1, the very first paragraph of useradd(8) tells you, not to use it, but adduser.