T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

Useradd��Adduser�����û�����ʹ�÷���

�� �������ߣ����� ����ʱ�䣺2008-01-18 | ���壺�� �� С��
[����]�����û�������useradd��adduser ���������������ﵽ��Ŀ�Ķ���һ���ģ���Fedora ���а���,useradd ��adduser �÷���һ���ģ�����slackware���а汾�У�adduser��useradd ����������ͬ������Ϊadduser �����˻�������...

�����û�������useradd��adduser ���������������ﵽ��Ŀ�Ķ���һ���ģ���Fedora ���а���,useradd ��adduser �÷���һ���ģ�����slackware���а汾�У�adduser��useradd ����������ͬ������Ϊadduser �����˻����������ʵķ�ʽ�������û���

 

����useradd��adduser�������⣬���ǻ���ͨ���޸��û������ļ�/etc/passwd��/etc/groups�İ취��ʵ�֣�

 

��Ȼ����Ҳ��Ҫ����һЩ���а������û��������ߣ�����Fedora ���� system-config-users ���ߣ��������߱Ƚϼ򵥣��㼸�������������ɣ�

 

1��useradd ����

 

useradd ���Ӳ���ѡ��ʱ������ֱ�Ӹ������ӵ��û���ʱ��ϵͳʱ��ȡ�����û������ļ�/etc/login.defs��/etc/default/useradd�� ����Ȼ����ȡ/etc/login.defs��/etc/default/useradd���������Ĺ��������û�������/etc/passwd�� /etc/groups�ļ������û����û�����¼����Ȼ/etc/passwd��/etc/groups�ļ�����Ѷ�ļ�Ҳͬ�����ɼ�¼��ͬʱ�����Ļ���ϵ ͳ���Զ���/etc/add/default����Լ����Ŀ¼�н��û��ļ�Ŀ¼��������/etc/skel�е��ļ������������ļ��������û��ļ�Ŀ¼�У�

 

useradd ���﷨��

 

usage: useradd [-u uid [-o]] [-g group] [-G group,...]

[-d home] [-s shell] [-c comment] [-m [-k template]]

[-f inactive] [-e expire ] [-p passwd] name

useradd -D [-g group] [-b base] [-s shell]

[-f inactive] [-e expire ]

������ִ��useradd �û��� �������û�ʱ�����ǻᷢ��һ���Ƚ�����˼�������������е��û��ļ�Ŀ¼���DZ��Զ����ӵ� /homeĿ¼�£������Ⱦٸ����ӣ�

 

ʵ��һ�������κβ�����ֱ�������û���

 

[root@localhost beinan]# useradd beinanlinux

[root@localhost beinan]# ls -ld /home/beinanlinux/

drwxr-xr-x 3 beinanlinux beinanlinux 4096 11�� 2 15:20 /home/beinanlinux/

�����������У�����������beinanlinux�û��������ڲ鿴/home/Ŀ¼ʱ���ᷢ��ϵͳ�Խ���һ��beinanlinux��Ŀ¼��

 

���������鿴 /etc/passwd �ļ��й�beinanlinux�ļ�¼��Ҳ�����·��֣�����ͨ��more ����ȡ /etc/passwd �ļ�������ͨ��grep ����ȡ beinanlinux�ֶΣ��ó�����һ�У�

 

[root@localhost beinan]# more /etc/passwd | grep beinanlinux

beinanlinux:x:509:509::/home/beinanlinux:/bin/bash

�ӵó���beinanlinux�ļ�¼��������adduser ��������beinanlinux�û�ʱ�������û���UID��GID�ֱ�Ϊ509 �����Ұ�beinanlinux�ļ�Ŀ¼������ /home/beinanlinux �����е�SHELL�� bash �� ������������ /etc/shadow��/etc/groups��/etc/gshadow �ļ����Dz���Ҳ����beinanlinux�йص��У����ǻ�Ҫ�鿴/etc/default/useradd ��/etc/login.defs�ļ��Ĺ��򣬿�һ��beinanlinux�û��������Dz��Ǻ������������ļ��йأ����ǻ�Ҫ�鿴 /home/beinanlinuxĿ¼�µ��ļ����Dz��Ǻ�/etc/skelĿ¼�е�һ����

 

�ɴ�������������������Ҫ̸�����ݣ�

 

useradd -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ]

 

1��/etc/default/useradd �����ļ��Ķ��壻

 

useradd -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ]

 

useradd ��-D�����󣬾��������ı������ļ� /etc/default/useradd�ģ�

 

useradd -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ]

 

��-Dѡ������ʱ��useradd�������ڵ�Ԥ��ֵ�����ǽ��������еķ�ʽ����Ԥ��ֵ������ѡ��Ϊ��

-b default_home ע�������û�����Ŀ¼��ǰһ��Ŀ¼���û����ƻḽ����default_home���������������û���Ŀ¼����Ȼʹ��-d������ѡ����Ч��

-e default_expire_date ע���û��ʺ�ֹͣ���ڡ�

-f default_inactive ע���ʺŹ��ڼ��պ�ͣȨ��

-g default_group ע�����ʺ���ʼ�û�������ID���û�������Ϊ���д��ڵ����ơ��û���IDҲ��Ϊ���д��ڵ��û��顣

-s default_shell ע���û�������ʹ�õ�shell���ơ������¼������ʺŶ���ʹ�ô�shell.

�粻ָ���κβ�����useradd��ʾĿǰԤ����ֵ��

 

ʵ������

useradd -D �粻ָ���κβ�����useradd��ʾĿǰԤ����ֵ��

 

[root@localhost beinan]# useradd -D

GROUP=100

HOME=/home

INACTIVE=-1

EXPIRE=

SHELL=/bin/bash

SKEL=/etc/skel

CREATE_MAIL_SPOOL=no

���ǿ�һ��/etc/default/useradd �ļ��������ˣ�Ӧ�ú�������������һ���ģ����������������ı�useradd�����ļ�/etc/default/adduser �����ݣ�Ҳ�����ñ༭��ֱ�Ӳ���������������vi�༭�����������༭���Ļ�������Ӧ�ò��������ɣ�

 

ʵ������

 

�����������û�ʱ��Ĭ��SHELL /bin/bash ��Ϊ /bin/tcsh ����Ӧ�������������

 

[root@localhost beinan]# useradd -D -s /bin/tcsh ע���������û�ʱ��SHELL ��Ϊtcsh ��

[root@localhost beinan]# more /etc/default/useradd ע���鿴�Ƿ��ɹ���

# useradd defaults file

GROUP=100

HOME=/home

INACTIVE=-1

EXPIRE=

SHELL=/bin/tcsh ע���ɹ���

SKEL=/etc/skel

CREATE_MAIL_SPOOL=no

����-D�����Ľ�˵�������ˣ�Ҳ�DZȽϼ򵥣��������������ֱ�ӸIJ��������ļ��ܻ��ɣ�Linux���������Ǽ�Ϊ�����ģ��Ϳ�������ô�����ˣ��Բ��ԣ�

 

2��useradd �����û���

 

useradd [-u uid [-o]] [-g group] [-G group,...]

[-d home] [-s shell] [-c comment] [-m [-k template]]

[-f inactive] [-e expire ] [-p passwd] name

���ʺŽ�����������-D����,useraddָ��ʹ����������ָ�����ʺŵ��趨ֵ andʹ��ϵͳ�ϵ�Ԥ��ֵ.���û��ʺŽ�����һЩϵͳ�������û�Ŀ¼������������ʼ�����ȣ���Щ����������������ѡ��ָ�����˰汾ΪRedHat Linux�ṩ���ɰ�ÿ���¼������û�����������group,��������-nѡ�

 

useradd ��ʹ�õ�ѡ��Ϊ

-c comment ע�����ʺ� password ����˵���� ��

-d home_dir ע�����ʺ�ÿ�ε���ʱ��ʹ�õ�home_dir��Ԥ��ֵΪdefault_home��login���ƣ������ɵ���ʱĿ¼���ơ�

-e expire_date ע���ʺ���ֹ���ڡ����ڵ�ָ����ʽΪMM/DD/YY��

-f inactive_days ע���ʺŹ��ڼ��պ�����ͣȨ����ֵΪ0ʱ�ʺ������̱�ͣȨ������ֵΪ-1ʱ���رմ˹��ܣ�Ԥ��ֵΪ-1

-g initial_group ע��group���ƻ�����������Ϊ�û�������ʼ�û���(group)���û�������Ϊ���д��ڵ����ơ��û�������Ҳ��Ϊ���д��ڵ��û��顣Ԥ�����û�������Ϊ1��

-G group,[...]

ע���������û�Ϊ��һ��groups�ij�Ա��ÿ���û���ʹ��","���������������Լ��ӿհ���Ԫ���û�����ͬ-gѡ�������ơ�����ֵΪ�û�����ʼ�û��顣��

-m ע���û�Ŀ¼�粻�������Զ���������ʹ��-kѡ��skeleton_dir�ڵĵ������������û�Ŀ¼�¡�Ȼ����/etc/skelĿ¼�µĵ���Ҳ�Ḵ�ƹ� ȥȡ�����κ���skeleton_dir or /etc/skel��Ŀ¼Ҳ��ͬ�����û�Ŀ¼��һһ������The-kͬ-m������Ŀ¼�Լ��������κε���ΪԤ��ֵ��

-M �������û�Ŀ¼����ʹ/etc/login.defsϵͳ���趨Ҫ�����û�Ŀ¼��

-n Ԥ��ֵ�û��û������û����ƻ���ͬ����ѡ�ȡ����Ԥ��ֵ��

-r �˲�������������ϵͳ�ʺš�ϵͳ�ʺŵ�UID���ȶ�����ϵͳ����/etc/login.defs.��UID_MIN����С��ע��useradd���÷����� �����ʺŲ��Ὠ���û�Ŀ¼��Ҳ�����ں���¼��/etc/login.defs.�Ķ���ֵ����������Ҫ���û�Ŀ¼������ָ��-m����������ϵͳ�ʺš�

-s shell ע���û�������ʹ�õ�shell���ơ�Ԥ��Ϊ����д������ϵͳ������ָ��Ԥ���ĵ���shell��

-u uid uid�û���IDֵ������ΪΨһ��IDֵ��������-oѡ����ֲ���Ϊ��ֵ��Ԥ��Ϊ��/etc/login.defs�е�UID_MIN��ֵΪ׼��0��UID_MIN��ֵ֮�䣬Ϊϵͳ������UID ��

useradd ��ô���IJ�������ȥͷ�е��Σ������������أ�����ʵ�ܼ򵥣�һ������һ����������һ�Բ��������ˣ����������õ�ѧϰ������ʵ���Ǽ���������Ψһ��׼��

 

����useradd ����ֱ�Ӹ��û����������κβ�������ʾ�����û�ʱ������/etc/default/adduser ��/etc/login.defs �������û��������ļ��Ĺ����������û�����ʵ����Ϊ�˷��㣬Ҳ���԰��������ļ��޸����ʺ����������û���Ҫ��

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:7.04ms QueryTime:7