There is no user directory when linux creates a new user

There is no user directory when linux creates a new user

**Problem:** After using useradd -d /home/user02 user02 to create a new user and specify a directory, the directory of user02 cannot be seen with ls /home.
insert image description here
Solution:

  • Use useradd -m username to create a folder with the same name under the /home directory.
    insert image description here

  • First create a directory with mkdir /home/username, then use useradd -d /home/username username to create a new user.
    insert image description here

useradd option:

  • The -d directory specifies the user's home directory. If this directory does not exist, use the -m option at the same time to create the home directory.
  • -m dir Create the user's home directory.
  • -g usergroup Specifies the usergroup to which the user belongs.
  • -G usergroup,usergroup Specifies additional groups to which the user belongs.
  • -s Shell file Specifies the user's login shell.
  • -u user number specifies the user number of the user. If there is the -o option at the same time, the identification number of other users can be reused.

Guess you like

Origin blog.csdn.net/weixin_45773137/article/details/124703490