0

I setup a factory new ubuntu 22.04.

I run useradd test1, there is no home directory created.

I run useradd -m test2, there is home directory with ~/.bashrc and some other environment files. But the bash script doesn't seem to work: here is a screenshot

root@jenkins-slave02:/home# useradd -m test3
root@jenkins-slave02:/home# su - test3
$
$
$
$ ls -la
total 20
drwxr-x--- 2 test3 test3 4096 Jun  7 05:15 .
drwxr-xr-x 5 root  root  4096 Jun  7 05:15 ..
-rw-r--r-- 1 test3 test3  220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 test3 test3 3771 Jan  6  2022 .bashrc
-rw-r--r-- 1 test3 test3  807 Jan  6  2022 .profile
$ set
HOME='/home/test3'
IFS='
'
LANG='en_US.UTF-8'
LOGNAME='test3'
MAIL='/var/mail/test3'
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
PPID='4019868'
PS1='$ '
PS2='> '
PS4='+ '
PWD='/home/test3'
SHELL='/bin/sh'
TERM='xterm'
USER='test3'
XDG_DATA_DIRS='/usr/local/share:/usr/share:/var/lib/snapd/desktop'
_='-la'
snap_bin_path='/snap/bin'
snap_xdg_path='/var/lib/snapd/desktop'
$
$ cd /etc/skel
$ ls
$ ls -la
total 20
drwxr-xr-x   2 root root 4096 Feb 17 17:23 .
drwxr-xr-x 105 root root 4096 Jun  7 05:15 ..
-rw-r--r--   1 root root  220 Jan  6  2022 .bash_logout
-rw-r--r--   1 root root 3771 Jan  6  2022 .bashrc
-rw-r--r--   1 root root  807 Jan  6  2022 .profile
$ pwd
/etc/skel
$

I don't modify /etc/skel, and here is my useradd -D output

root@jenkins-slave02:/home# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/sh
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
root@jenkins-slave02:/home#

I don't know why. Please help.

  • Please don't post screenshots of text. Copy the text here and use code formatting: https://askubuntu.com/editing-help#code. And what is that screenshot supposed to show? – muru Jun 07 '23 at 05:33
  • Hello @muru I update the text. I want to say some environment variable don't work. For example PS1, there is no shell promt, no keyboard shortcuts like tab is act as \t not bash complete and so on... – Bryan Chen Jun 07 '23 at 05:54
  • I find out that the reason is SHELL=/bin/sh, not bash – Bryan Chen Jun 07 '23 at 06:35
  • You can set the default value for SHELL in /etc/default/useradd – muru Jun 07 '23 at 07:03
  • yes, really appreciated. – Bryan Chen Jun 08 '23 at 05:30

1 Answers1

0

According to What is the difference between adduser and useradd?. I realized there is another command adduser in ubuntu.