ubuntu和centos创建用户的区别

Posted 白-胖-子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu和centos创建用户的区别相关的知识,希望对你有一定的参考价值。

  • 在CentOS下习惯使用使用useradd进行用户的创建,但是ubuntu下,如果单纯使用useradd进行用户创建,则不会自动生成该用户的home目录和邮箱之类的。

  • 在ubuntu下使用adduser进行用户创建,会进入交互模式,可同时对用户进行多种信息的录入

  • CentOS useradd创建用户
    默认创建用户家目录
    默认 shell 解释器为 bash免交互创建密码–stdin

  • Ubuntu useradd创建用户
    默认不创建用户家目录
    默认 shell 解释器为 sh免交互创建密码 chpasswd

[root@U20-ptyhon-191 ~]# adduser --htlp
Unknown option: htlp
adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
[--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID]
[--disabled-password] [--disabled-login] [--add_extra_groups]
[--encrypt-home] USER
   Add a normal user

adduser --system [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
[--gecos GECOS] [--group | --ingroup GROUP | --gid ID] [--disabled-password]
[--disabled-login] [--add_extra_groups] USER
   Add a system user

adduser --group [--gid ID] GROUP
addgroup [--gid ID] GROUP
   Add a user group

addgroup --system [--gid ID] GROUP
   Add a system group

adduser USER GROUP
   Add an existing user to an existing group

general options:
  --quiet | -q      don't give process information to stdout
  --force-badname   allow usernames which do not match the
                    NAME_REGEX[_SYSTEM] configuration variable
  --extrausers      uses extra users as the database
  --help | -h       usage message
  --version | -v    version number and copyright
  --conf | -c FILE  use FILE as configuration file

[root@U20-ptyhon-191 ~]# adduser python
Adding user `python' ...
Adding new group `python' (1001) ...
Adding new user `python' (1001) with group `python' ...
The home directory `/home/python' already exists.  Not copying from `/etc/skel'.
adduser: Warning: The home directory `/home/python' does not belong to the user you are currently creating.
New password: 
Retype new password: 
Sorry, passwords do not match.
passwd: Authentication token manipulation error
passwd: password unchanged
Try again? [y/N] y
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for python
Enter the new value, or press ENTER for the default
	Full Name []: python
	Room Number []: 302
	Work Phone []: 302
	Home Phone []: 302
	Other []: 
Is the information correct? [Y/n] y
[root@U20-ptyhon-191 ~]# su - python
python@U20-ptyhon-191:~$ pwd
/home/python
python@U20-ptyhon-191:~$ 

  • useradd
NAME
       useradd - create a new user or update default new user information

SYNOPSIS
       useradd [options] LOGIN

       useradd -D

       useradd -D [options]

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

       When invoked without the -D option, the useradd command creates a new
       user account using the values specified on the command line plus the
       default values from the system. Depending on command line options, the
       useradd command will update system files and may also create the new
       user's home directory and copy initial files.

       By default, a group will also be created for the new user (see -g, -N,
       -U, and USERGROUPS_ENAB).
  • adduser
NAME
       adduser, addgroup - add a user or group to the system
DESCRIPTION
       adduser  and  addgroup  add users and groups to the system according to
       command  line  options  and  configuration  information   in   /etc/ad‐
       duser.conf.  They are friendlier front ends to the low level tools like
       useradd, groupadd and usermod programs, by default choosing Debian pol‐
       icy  conformant  UID  and  GID  values,  creating a home directory with
       skeletal configuration, running a custom script,  and  other  features.
       adduser and addgroup can be run in one of five modes:

以上是关于ubuntu和centos创建用户的区别的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu 和centos 有啥区别?

Ubuntu 和centos 有啥区别

centos和ubuntu区别

centos和ubuntu有啥区别

centos和Ubuntu区别

Docker镜像分层存储与镜像精简