linux讲义_用户与组管理命令练习.doc
文本预览下载声明
用户和组管理基本用户环境主目录: 用户登录后所在的目录,名称与用户名相同,在/etc/passwd文件的最后一个域中指定。/etc/skel: 其中的目录及文件在新建用户时自动拷贝到用户主目录下。几个重要文件用户定义文件: /etc/passwd组定义文件: /etc/group口令文件: /etc/shadow一、用户和组文件用户账号文件——passwd passwd文件用于定义系统的用户账号,该文件位于“/etc”目录下。由于所有用户都对 passwd有读权限,所以该文件中只定义用户账号,而不保存口令。#11/etc/passwd-rw-r#11/etc/passwd-rw-r—r-- 1 root root 1359 May 23 16:09 /etc/passwd passwd文件中每行定义一个用户账号,一行中又划分为多个字段定义用户账号的不同属性,各字段间用“:”分隔。passwd文件的各字段如表6-1所示。//使用head命令查看passwd文件的前10行#head /etc/passwd//使用head命令查看passwd文件的前10行#head /etc/passwdroot:x:0:0:root:/root:/bin/bash表6-1 passwd文件按字段划分accountpasswordUIDGIDGECOSdirectoryshellrootx00root/root/bin/bashbinx10bin/bin/sbin/nologin passwd文件中各字段的含义如表6-2所示,其中少数字段的内容是可以为空的,但仍需使用“:”进行占位来表示该字段。字段命 名account用户账号名称,用户登录时所使用的用户名 password用户口令,出于安全性考虑,现在已经不使用该字段保存口令,而用字母“x”来填充该字段,真正的的密码保存在shadow文件中 UID用户号,惟一表示某用户的数宇 GID用户所属的私有组号,该数字对应group文件中的GIDGECOS可选的用户信息说明字段,通常用于保存用户全名的信息directory用户的宿主目录,用户成功登录后的默认目录shell用户所使用的shell,如该字段为空则使用“/bin/sh”用户口令文件——shadowshadow文件位于“/etc”目录中,用于存放用户口令等重要信息,所以该文件只有root用户可以读取。 与passwd文件类似,shadow文件中每行定义一个用户的信息,行中的各字段用“:”分隔。为了进一步提高安全性,shadow文件中保存的是已加密的口令。可以使用#head /etc/shadow命令查看前10行的内容。shadow文件的定义:Username:The name the user types when logging into the system. This allows the login appli-cationto retrieve the users password (and related information). Encrypted password:The 13 to 24 character password. The password is encrypted using either the crypt library function, or the md5 hash algorithm. In this field, values other than a validly-formatted encrypted or hashed password are used to control user logins and to show the password status. For example, if the value is ! or * the account is locked, and the user is not allowed to login. Date password last changed:The number of days since January 1, 1970 (also called the epoch)that the password was last changed. This information is used for the following password aging fields. Number of days before password can be changed:The minimum number of days that must p
显示全部