Linux 用户和用户组管理657
Linux 用户和用户组管理
Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。
用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问;另一方面也可以帮助用户组织文件,并为用户提供安全性保护。
每个用户账号都拥有一个唯一的用户名和各自的口令。
用户在登录时键入正确的用户名和口令后,就能够进入系统和自己的主目录。
实现用户账号的管理,要完成的工作主要有如下几个方面:
- 用户账号的添加、删除与修改。
- 用户口令的管理。
- 用户组的管理。
一、Linux系统用户账号的管理
用户账号的管理工作主要涉及到用户账号的添加、修改和删除。
添加用户账号就是在系统中创建一个新账号,然后为新账号分配用户号、用户组、主目录和登录Shell等资源。刚添加的账号是被锁定的,无法使用。
1、添加新的用户账号使用useradd命令,其语法如下:
useradd 选项 用户名
参数说明:
-
选项:
- -c comment 指定一段注释性描述。
- -d 目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
- -g 用户组 指定用户所属的用户组。
- -G 用户组,用户组 指定用户所属的附加组。
- -s Shell文件 指定用户的登录Shell。
- -u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。
-
用户名:
指定新账号的登录名。
实例1
# useradd –d /home/sam -m sam
此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录 /home/sam(/home为默认的用户主目录所在的父目录)。
实例2
# useradd -s /bin/sh -g group –G adm,root gem
此命令新建了一个用户gem,该用户的登录Shell是 /bin/sh,它属于group用户组,同时又属于adm和root用户组,其中group用户组是其主组。
这里可能新建组:#groupadd group及groupadd adm
增加用户账号就是在/etc/passwd文件中为新用户增加一条记录,同时更新其他系统文件如/etc/shadow, /etc/group等。
Linux提供了集成的系统管理工具userconf,它可以用来对用户账号进行统一管理。
2、删除帐号
如果一个用户的账号不再使用,可以从系统中删除。删除用户账号就是要将/etc/passwd等系统文件中的该用户记录删除,必要时还删除用户的主目录。
删除一个已有的用户账号使用userdel命令,其格式如下:
userdel 选项 用户名
常用的选项是 -r,它的作用是把用户的主目录一起删除。
例如:
# userdel -r sam
此命令删除用户sam在系统文件中(主要是/etc/passwd, /etc/shadow, /etc/group等)的记录,同时删除用户的主目录。
3、修改帐号
修改用户账号就是根据实际情况更改用户的有关属性,如用户号、主目录、用户组、登录Shell等。
修改已有用户的信息使用usermod命令,其格式如下:
usermod 选项 用户名
常用的选项包括-c, -d, -m, -g, -G, -s, -u以及-o等,这些选项的意义与useradd命令中的选项一样,可以为用户指定新的资源值。
另外,有些系统可以使用选项:-l 新用户名
这个选项指定一个新的账号,即将原来的用户名改为新的用户名。
例如:
# usermod -s /bin/ksh -d /home/z –g developer sam
此命令将用户sam的登录Shell修改为ksh,主目录改为/home/z,用户组改为developer。
4、用户口令的管理
用户管理的一项重要内容是用户口令的管理。用户账号刚创建时没有口令,但是被系统锁定,无法使用,必须为其指定口令后才可以使用,即使是指定空口令。
指定和修改用户口令的Shell命令是passwd。超级用户可以为自己和其他用户指定口令,普通用户只能用它修改自己的口令。命令的格式为:
passwd 选项 用户名
可使用的选项:
- -l 锁定口令,即禁用账号。
- -u 口令解锁。
- -d 使账号无口令。
- -f 强迫用户下次登录时修改口令。
如果默认用户名,则修改当前用户的口令。
例如,假设当前用户是sam,则下面的命令修改该用户自己的口令:
$ passwd Old password:****** New password:******* Re-enter new password:*******
如果是超级用户,可以用下列形式指定任何用户的口令:
# passwd sam New password:******* Re-enter new password:*******
普通用户修改自己的口令时,passwd命令会先询问原口令,验证后再要求用户输入两遍新口令,如果两次输入的口令一致,则将这个口令指定给用户;而超级用户为用户指定口令时,就不需要知道原口令。
为了系统安全起见,用户应该选择比较复杂的口令,例如最好使用8位长的口令,口令中包含有大写、小写字母和数字,并且应该与姓名、生日等不相同。
为用户指定空口令时,执行下列形式的命令:
# passwd -d sam
此命令将用户 sam 的口令删除,这样用户 sam 下一次登录时,系统就不再允许该用户登录了。
passwd 命令还可以用 -l(lock) 选项锁定某一用户,使其不能登录,例如:
# passwd -l sam
二、Linux系统用户组的管理
每个用户都有一个用户组,系统可以对一个用户组中的所有用户进行集中管理。不同Linux 系统对用户组的规定有所不同,如Linux下的用户属于与它同名的用户组,这个用户组在创建用户时同时创建。
用户组的管理涉及用户组的添加、删除和修改。组的增加、删除和修改实际上就是对/etc/group文件的更新。
1、增加一个新的用户组使用groupadd命令。其格式如下:
groupadd 选项 用户组
可以使用的选项有:
- -g GID 指定新用户组的组标识号(GID)。
- -o 一般与-g选项同时使用,表示新用户组的GID可以与系统已有用户组的GID相同。
实例1:
# groupadd group1
此命令向系统中增加了一个新组group1,新组的组标识号是在当前已有的最大组标识号的基础上加1。
实例2:
# groupadd -g 101 group2
此命令向系统中增加了一个新组group2,同时指定新组的组标识号是101。
2、如果要删除一个已有的用户组,使用groupdel命令,其格式如下:
groupdel 用户组
例如:
# groupdel group1
此命令从系统中删除组group1。
3、修改用户组的属性使用groupmod命令。其语法如下:
groupmod 选项 用户组
常用的选项有:
- -g GID 为用户组指定新的组标识号。
- -o 与-g选项同时使用,用户组的新GID可以与系统已有用户组的GID相同。
- -n新用户组 将用户组的名字改为新名字
实例1:
# groupmod -g 102 group2
此命令将组group2的组标识号修改为102。
实例2:
# groupmod –g 10000 -n group3 group2
此命令将组group2的标识号改为10000,组名修改为group3。
4、如果一个用户同时属于多个用户组,那么用户可以在用户组之间切换,以便具有其他用户组的权限。
用户可以在登录后,使用命令newgrp切换到其他用户组,这个命令的参数就是目的用户组。例如:
$ newgrp root
这条命令将当前用户切换到root用户组,前提条件是root用户组确实是该用户的主组或附加组。类似于用户账号的管理,用户组的管理也可以通过集成的系统管理工具来完成。
三、与用户账号有关的系统文件
完成用户管理的工作有许多种方法,但是每一种方法实际上都是对有关的系统文件进行修改。
与用户和用户组相关的信息都存放在一些系统文件中,这些文件包括/etc/passwd, /etc/shadow, /etc/group等。
下面分别介绍这些文件的内容。
1、/etc/passwd文件是用户管理工作涉及的最重要的一个文件。
Linux系统中的每个用户都在/etc/passwd文件中有一个对应的记录行,它记录了这个用户的一些基本属性。
这个文件对所有用户都是可读的。它的内容类似下面的例子:
https://avg.163.com/topic/detail/10634945
https://avg.163.com/topic/detail/10634944
https://avg.163.com/topic/detail/10634943
https://avg.163.com/topic/detail/10634942
https://avg.163.com/topic/detail/10634941
https://avg.163.com/topic/detail/10634940
https://avg.163.com/topic/detail/10634939
https://avg.163.com/topic/detail/10634938
https://avg.163.com/topic/detail/10634900
https://avg.163.com/topic/detail/10634899
https://avg.163.com/topic/detail/10634937
https://avg.163.com/topic/detail/10634935
https://avg.163.com/topic/detail/10634936
https://avg.163.com/topic/detail/10634933
https://avg.163.com/topic/detail/10634934
https://avg.163.com/topic/detail/10634932
https://avg.163.com/topic/detail/10634931
https://avg.163.com/topic/detail/10634930
https://avg.163.com/topic/detail/10634898
https://avg.163.com/topic/detail/10634929
https://avg.163.com/topic/detail/10634927
https://avg.163.com/topic/detail/10634889
https://avg.163.com/topic/detail/10634926
https://avg.163.com/topic/detail/10634923
https://avg.163.com/topic/detail/10634925
https://avg.163.com/topic/detail/10634924
https://avg.163.com/topic/detail/10634888
https://avg.163.com/topic/detail/10634922
https://avg.163.com/topic/detail/10634921
https://avg.163.com/topic/detail/10634920
https://avg.163.com/topic/detail/10634919
https://avg.163.com/topic/detail/10634918
https://avg.163.com/topic/detail/10634917
https://avg.163.com/topic/detail/10634846
https://avg.163.com/topic/detail/10634915
https://avg.163.com/topic/detail/10634890
https://avg.163.com/topic/detail/10634914
https://avg.163.com/topic/detail/10634912
https://avg.163.com/topic/detail/10633576
https://avg.163.com/topic/detail/10634866
https://avg.163.com/topic/detail/10634911
https://avg.163.com/topic/detail/10634909
https://avg.163.com/topic/detail/10634908
https://avg.163.com/topic/detail/10634907
https://avg.163.com/topic/detail/10634906
https://avg.163.com/topic/detail/10634905
https://avg.163.com/topic/detail/10634904
https://avg.163.com/topic/detail/10634864
https://avg.163.com/topic/detail/10634903
https://avg.163.com/topic/detail/10634902
https://avg.163.com/topic/detail/10634901
https://avg.163.com/topic/detail/10634014
https://avg.163.com/topic/detail/10634900
https://avg.163.com/topic/detail/10634899
https://avg.163.com/topic/detail/10634898
https://avg.163.com/topic/detail/10634897
https://avg.163.com/topic/detail/10634896
https://avg.163.com/topic/detail/10634895
https://avg.163.com/topic/detail/10634894
https://avg.163.com/topic/detail/10634893
https://avg.163.com/topic/detail/10634892
https://avg.163.com/topic/detail/10634891
https://avg.163.com/topic/detail/10634890
https://avg.163.com/topic/detail/10633831
https://avg.163.com/topic/detail/10634889
https://avg.163.com/topic/detail/10634888
https://avg.163.com/topic/detail/10634887
https://avg.163.com/topic/detail/10634842
https://avg.163.com/topic/detail/10634886
https://avg.163.com/topic/detail/10634885
https://avg.163.com/topic/detail/10634884
https://avg.163.com/topic/detail/10634883
https://avg.163.com/topic/detail/10634882
https://avg.163.com/topic/detail/10634881
https://avg.163.com/topic/detail/10634832
https://avg.163.com/topic/detail/10634880
https://avg.163.com/topic/detail/10633576
https://avg.163.com/topic/detail/10634879
https://avg.163.com/topic/detail/10634878
https://avg.163.com/topic/detail/10634877
https://avg.163.com/topic/detail/10634876
https://avg.163.com/topic/detail/10634670
https://avg.163.com/topic/detail/10634875
https://avg.163.com/topic/detail/10634873
https://avg.163.com/topic/detail/10634874
https://avg.163.com/topic/detail/10634872
https://avg.163.com/topic/detail/10634672
https://avg.163.com/topic/detail/10634871
https://avg.163.com/topic/detail/10634014
https://avg.163.com/topic/detail/10634870
https://avg.163.com/topic/detail/10634869
https://avg.163.com/topic/detail/10634868
https://avg.163.com/topic/detail/10634867
https://avg.163.com/topic/detail/10634866
https://avg.163.com/topic/detail/10634865
https://avg.163.com/topic/detail/10634757
https://avg.163.com/topic/detail/10634864
https://avg.163.com/topic/detail/10633925
https://avg.163.com/topic/detail/10634577
https://avg.163.com/topic/detail/10634440
https://avg.163.com/topic/detail/10634863
https://avg.163.com/topic/detail/10634509
https://avg.163.com/topic/detail/10634862
https://avg.163.com/topic/detail/10634587
https://avg.163.com/topic/detail/10634861
https://avg.163.com/topic/detail/10634860
https://avg.163.com/topic/detail/10633906
https://avg.163.com/topic/detail/10633831
https://avg.163.com/topic/detail/10634851
https://avg.163.com/topic/detail/10634850
https://avg.163.com/topic/detail/10634849
https://avg.163.com/topic/detail/10634848
https://avg.163.com/topic/detail/10634843
https://avg.163.com/topic/detail/10634846
https://avg.163.com/topic/detail/10634845
https://avg.163.com/topic/detail/10634844
https://avg.163.com/topic/detail/10633449
https://avg.163.com/topic/detail/10634842
https://avg.163.com/topic/detail/10634841
https://avg.163.com/topic/detail/10634834
https://avg.163.com/topic/detail/10634833
https://avg.163.com/topic/detail/10634832
https://avg.163.com/topic/detail/10634831
https://avg.163.com/topic/detail/10634800
https://avg.163.com/topic/detail/10634079
https://avg.163.com/topic/detail/10634776
https://avg.163.com/topic/detail/10634724
https://avg.163.com/topic/detail/10634758
https://avg.163.com/topic/detail/10634759
https://avg.163.com/topic/detail/10634757
https://avg.163.com/topic/detail/10634506
https://avg.163.com/topic/detail/10633576
https://avg.163.com/topic/detail/10634755
https://avg.163.com/topic/detail/10634743
https://avg.163.com/topic/detail/10634726
https://avg.163.com/topic/detail/10634709
https://avg.163.com/topic/detail/10634699
https://avg.163.com/topic/detail/10634695
https://avg.163.com/topic/detail/10634672
https://avg.163.com/topic/detail/10634671
https://avg.163.com/topic/detail/10634670
https://avg.163.com/topic/detail/10634668
https://avg.163.com/topic/detail/10634194
https://avg.163.com/topic/detail/10634625
https://avg.163.com/topic/detail/10633906
https://avg.163.com/topic/detail/10634587
https://avg.163.com/topic/detail/10634586
https://avg.163.com/topic/detail/10634577
https://avg.163.com/topic/detail/10634014
https://avg.163.com/topic/detail/10634450
https://avg.163.com/topic/detail/10634518
https://avg.163.com/topic/detail/10634509
https://avg.163.com/topic/detail/10634507
https://avg.163.com/topic/detail/10633840
https://avg.163.com/topic/detail/10634497
https://avg.163.com/topic/detail/10634494
https://avg.163.com/topic/detail/10634486
https://avg.163.com/topic/detail/10632851
https://avg.163.com/topic/detail/10634440
https://avg.163.com/topic/detail/10634435
https://avg.163.com/topic/detail/10633812
https://avg.163.com/topic/detail/10634419
https://avg.163.com/topic/detail/10633831
https://avg.163.com/topic/detail/10634415
https://avg.163.com/topic/detail/10633449
https://avg.163.com/topic/detail/10633925
https://avg.163.com/topic/detail/10634364
https://avg.163.com/topic/detail/10634360
https://avg.163.com/topic/detail/10633791
https://avg.163.com/topic/detail/10634335
https://avg.163.com/topic/detail/10634325
https://avg.163.com/topic/detail/10634315
https://avg.163.com/topic/detail/10634305
https://avg.163.com/topic/detail/10634283
https://avg.163.com/topic/detail/10633770
https://avg.163.com/topic/detail/10634279
https://avg.163.com/topic/detail/10633144
https://avg.163.com/topic/detail/10634269
https://avg.163.com/topic/detail/10634275
https://avg.163.com/topic/detail/10634253
https://avg.163.com/topic/detail/10633759
https://avg.163.com/topic/detail/10634208
https://avg.163.com/topic/detail/10634211
https://avg.163.com/topic/detail/10634196
https://avg.163.com/topic/detail/10634189
https://avg.163.com/topic/detail/10634079
https://avg.163.com/topic/detail/10634194
https://avg.163.com/topic/detail/10633179
https://avg.163.com/topic/detail/10634150
https://avg.163.com/topic/detail/10633576
https://avg.163.com/topic/detail/10634133
https://avg.163.com/topic/detail/10634125
https://avg.163.com/topic/detail/10632740
https://avg.163.com/topic/detail/10634098
https://avg.163.com/topic/detail/10634088
https://avg.163.com/topic/detail/10634079
https://avg.163.com/topic/detail/10634078
https://avg.163.com/topic/detail/10634071
https://avg.163.com/topic/detail/10634065
https://avg.163.com/topic/detail/10633324
https://avg.163.com/topic/detail/10634014
https://avg.163.com/topic/detail/10633996
https://avg.163.com/topic/detail/10633995
https://avg.163.com/topic/detail/10633982
https://avg.163.com/topic/detail/10633979
https://avg.163.com/topic/detail/10633350
https://avg.163.com/topic/detail/10633925
https://avg.163.com/topic/detail/10633605
https://avg.163.com/topic/detail/10633906
https://avg.163.com/topic/detail/10633351
https://avg.163.com/topic/detail/10633876
https://avg.163.com/topic/detail/10632401
https://avg.163.com/topic/detail/10633099
https://avg.163.com/topic/detail/10632740
https://avg.163.com/topic/detail/10633840
https://avg.163.com/topic/detail/10633831
https://avg.163.com/topic/detail/10633812
https://avg.163.com/topic/detail/10633449
https://avg.163.com/topic/detail/10633791
https://avg.163.com/topic/detail/10633128
https://avg.163.com/topic/detail/10633770
https://avg.163.com/topic/detail/10633761
https://avg.163.com/topic/detail/10633759
https://avg.163.com/topic/detail/10633748
https://avg.163.com/topic/detail/10633746
https://avg.163.com/topic/detail/10633744
https://avg.163.com/topic/detail/10632459
https://avg.163.com/topic/detail/10633144
https://avg.163.com/topic/detail/10633689
https://avg.163.com/topic/detail/10633687
https://avg.163.com/topic/detail/10633688
https://avg.163.com/topic/detail/10633664
https://avg.163.com/topic/detail/10633349
https://avg.163.com/topic/detail/10633647
https://avg.163.com/topic/detail/10633643
https://avg.163.com/topic/detail/10633635
https://avg.163.com/topic/detail/10633605
https://avg.163.com/topic/detail/10633586
https://avg.163.com/topic/detail/10633576
https://avg.163.com/topic/detail/10633577
https://avg.163.com/topic/detail/10632401
https://avg.163.com/topic/detail/10633257
https://avg.163.com/topic/detail/10633514
https://avg.163.com/topic/detail/10632851
https://avg.163.com/topic/detail/10633496
https://avg.163.com/topic/detail/10633416
https://avg.163.com/topic/detail/10633482
https://avg.163.com/topic/detail/10633456
https://avg.163.com/topic/detail/10633449
https://avg.163.com/topic/detail/10633438
https://avg.163.com/topic/detail/10633427
https://avg.163.com/topic/detail/10633416
https://avg.163.com/topic/detail/10633411
https://avg.163.com/topic/detail/10633398
https://avg.163.com/topic/detail/10633407
https://avg.163.com/topic/detail/10633392
https://avg.163.com/topic/detail/10633386
https://avg.163.com/topic/detail/10633350
https://avg.163.com/topic/detail/10633351
https://avg.163.com/topic/detail/10633349
https://avg.163.com/topic/detail/10633324
https://avg.163.com/topic/detail/10633307
https://avg.163.com/topic/detail/10633250
https://avg.163.com/topic/detail/10633257
https://avg.163.com/topic/detail/10632596
https://avg.163.com/topic/detail/10632591
https://avg.163.com/topic/detail/10632709
https://avg.163.com/topic/detail/10632594
https://avg.163.com/topic/detail/10633183
https://avg.163.com/topic/detail/10633179
https://avg.163.com/topic/detail/10633158
https://avg.163.com/topic/detail/10632476
https://avg.163.com/topic/detail/10633099
https://avg.163.com/topic/detail/10633144
https://avg.163.com/topic/detail/10633128
https://avg.163.com/topic/detail/10633103
https://avg.163.com/topic/detail/10633083
https://avg.163.com/topic/detail/10633072
https://avg.163.com/topic/detail/10633055
https://avg.163.com/topic/detail/10633043
https://avg.163.com/topic/detail/10633039
https://avg.163.com/topic/detail/10633029
https://avg.163.com/topic/detail/10632987
https://avg.163.com/topic/detail/10632949
https://avg.163.com/topic/detail/10632914
https://avg.163.com/topic/detail/10632913
https://avg.163.com/topic/detail/10632510
https://avg.163.com/topic/detail/10632868
https://avg.163.com/topic/detail/10632851
https://avg.163.com/topic/detail/10632855
https://avg.163.com/topic/detail/10632820
https://avg.163.com/topic/detail/10632794
https://avg.163.com/topic/detail/10632780
https://avg.163.com/topic/detail/10632778
https://avg.163.com/topic/detail/10632776
https://avg.163.com/topic/detail/10632763
https://avg.163.com/topic/detail/10632740
https://avg.163.com/topic/detail/10632283
https://avg.163.com/topic/detail/10632505
https://avg.163.com/topic/detail/10632688
https://avg.163.com/topic/detail/10632678
https://avg.163.com/topic/detail/10632644
https://avg.163.com/topic/detail/10632591
https://avg.163.com/topic/detail/10632597
https://avg.163.com/topic/detail/10632596
https://avg.163.com/topic/detail/10632594
https://avg.163.com/topic/detail/10632504
https://avg.163.com/topic/detail/10632530
https://avg.163.com/topic/detail/10632510
https://avg.163.com/topic/detail/10632505
https://avg.163.com/topic/detail/10632504
https://avg.163.com/topic/detail/10632503
https://avg.163.com/topic/detail/10632476
https://avg.163.com/topic/detail/10632459
https://avg.163.com/topic/detail/10632430
https://avg.163.com/topic/detail/10632428
https://avg.163.com/topic/detail/10632410
https://avg.163.com/topic/detail/10632401
https://avg.163.com/topic/detail/10632406
https://avg.163.com/topic/detail/10632405
https://avg.163.com/topic/detail/10632383
https://avg.163.com/topic/detail/10632378
https://avg.163.com/topic/detail/10632296
https://avg.163.com/topic/detail/10632333
https://avg.163.com/topic/detail/10632291
https://avg.163.com/topic/detail/10632283
https://avg.163.com/topic/detail/10632218
https://avg.163.com/topic/detail/10632216
https://avg.163.com/topic/detail/10632213
https://avg.163.com/topic/detail/10632208
https://avg.163.com/topic/detail/10632204
https://avg.163.com/topic/detail/10632201
https://avg.163.com/topic/detail/10632202
https://avg.163.com/topic/detail/10632198
https://avg.163.com/topic/detail/10632197
https://avg.163.com/topic/detail/10632195
https://avg.163.com/topic/detail/10632193
https://avg.163.com/topic/detail/10632191
https://avg.163.com/topic/detail/10632188
https://avg.163.com/topic/detail/10632187
https://avg.163.com/topic/detail/10632184
https://avg.163.com/topic/detail/10632182
# cat /etc/passwd root:x:0:0:Superuser:/: daemon:x:1:1:System daemons:/etc: bin:x:2:2:Owner of system commands:/bin: sys:x:3:3:Owner of system files:/usr/sys: adm:x:4:4:System accounting:/usr/adm: uucp:x:5:5:UUCP administrator:/usr/lib/uucp: auth:x:7:21:Authentication administrator:/tcb/files/auth: cron:x:9:16:Cron daemon:/usr/spool/cron: listen:x:37:4:Network daemon:/usr/net/nls: lp:x:71:18:Printer administrator:/usr/spool/lp: sam:x:200:50:Sam san:/home/sam:/bin/sh
从上面的例子我们可以看到,/etc/passwd中一行记录对应着一个用户,每行记录又被冒号(:)分隔为7个字段,其格式和具体含义如下:
用户名:口令:用户标识号:组标识号:注释性描述:主目录:登录Shell
1)"用户名"是代表用户账号的字符串。
通常长度不超过8个字符,并且由大小写字母和/或数字组成。登录名中不能有冒号(:),因为冒号在这里是分隔符。
为了兼容起见,登录名中最好不要包含点字符(.),并且不使用连字符(-)和加号(+)打头。
2)“口令”一些系统中,存放着加密后的用户口令字。
虽然这个字段存放的只是用户口令的加密串,不是明文,但是由于/etc/passwd文件对所有用户都可读,所以这仍是一个安全隐患。因此,现在许多Linux 系统(如SVR4)都使用了shadow技术,把真正的加密后的用户口令字存放到/etc/shadow文件中,而在/etc/passwd文件的口令字段中只存放一个特殊的字符,例如“x”或者“*”。
3)“用户标识号”是一个整数,系统内部用它来标识用户。
一般情况下它与用户名是一一对应的。如果几个用户名对应的用户标识号是一样的,系统内部将把它们视为同一个用户,但是它们可以有不同的口令、不同的主目录以及不同的登录Shell等。
通常用户标识号的取值范围是0~65 535。0是超级用户root的标识号,1~99由系统保留,作为管理账号,普通用户的标识号从100开始。在Linux系统中,这个界限是500。
4)“组标识号”字段记录的是用户所属的用户组。
它对应着/etc/group文件中的一条记录。
5)“注释性描述”字段记录着用户的一些个人情况。
例如用户的真实姓名、电话、地址等,这个字段并没有什么实际的用途。在不同的Linux 系统中,这个字段的格式并没有统一。在许多Linux系统中,这个字段存放的是一段任意的注释性描述文字,用做finger命令的输出。
6)“主目录”,也就是用户的起始工作目录。
它是用户在登录到系统之后所处的目录。在大多数系统中,各用户的主目录都被组织在同一个特定的目录下,而用户主目录的名称就是该用户的登录名。各用户对自己的主目录有读、写、执行(搜索)权限,其他用户对此目录的访问权限则根据具体情况设置。











