Sunday, April 28, 2024
141
rated 0 times [  141] [ 0]  / answers: 1 / hits: 307417  / 1 Year ago, sun, march 5, 2023, 11:41:29

I am trying to understand system administration on Ubuntu. So, as an example, I create a dummy user using



sudo useradd -d /home/linda linda


and passwd to create the password. I check that an entry has been made using cat /etc/passwd



linda:x:1004:1004::/home/linda:/bin/sh


However, when I su - linda, I get




No directory, logging in with HOME=/



and indeed, no home directory has been created. What am I missing?



Thanks.


More From » command-line

 Answers
4

man useradd states:



useradd is a low level utility for adding users. On Debian,
administrators should usually use adduser(8) instead.

Note the low level utility


To add a user, use adduser instead. It's a more high-level utility.




Moreover, looking at the -d option:


   -d, --home HOME_DIR
The new user will be created using HOME_DIR as the value for the
user's login directory. The default is to append the LOGIN name to
BASE_DIR and use that as the login directory name. The directory
HOME_DIR does not have to exist but will not be created if it is
missing.

The directory will not be created if it is missing.


Generally, keep away from useradd, use adduser instead.


[#28478] Tuesday, March 7, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
peafowkes

Total Points: 356
Total Questions: 102
Total Answers: 117

Location: Lebanon
Member since Tue, Oct 12, 2021
3 Years ago
peafowkes questions
;