One. Manage users and groups
- Linux users species:
root administrator, has supreme authority, without limitation, UID 0
User ordinary users created by the administrator, restricted permissions, UID is generally 500 to 60,000 , you can log into the system
Program users to install the application, created by the system, UID is generally 1 to 500 , generally can not log into the system, shell usually / sbin / nologin
-Linux in the group of species:
The basic group (private groups) a user has only one private group, when a user creates directories and files, directories and files belong to the default group is the basic group
Additional groups (communities), the user may have a plurality of additional groups
- User management:
/ Etc / passwd # store user information
root: User Accounts
x: Password placeholder
0:uid
0: guide
root: descriptive information
root: home directory
/ Bin / bash: login shell
/ Etc / shadow # store the user's password information, and the like (the / etc / passwd user information corresponding to each row)
Red part behind root: cipher text, usually with HASH algorithm generator
14374: From January 1, 1970 to the present time (in days)
0: Minimum password age
99999: maximum password expiration period
7: 7 days in advance of password expiration reminder
...: How long will account expired and failure to retain key
- Add user accounts
useradd command
useradd [option] ... username
-u: Specifies the UID tag number
-d: Specifies the home directory, defaults to / home / username (specified directory will be automatically created when the specified directory does not exist to replicate the initial configuration file)
-e: Specifies the account expiration time
-g: Basic group name specified user (or UID number)
-G:指定用户的附加组名(或GID号) (当指定的附加组不存在时,无法创建用户 )
-M:不为用户建立并初始化宿主目录
-s:指定用户的登录Shell
-设置/更改用户口令
passwd命令
passwd [选项]... 用户名
-d:清空用户的密码,使之无需密码即可登录
-l:锁定用户帐号
-S:查看用户帐号的状态(是否被锁定)
-u:解锁用户帐号
补充:标准输入:
echo "123456" | passwd --stdin test02
给test02账户设置密码123456
-exit
可以退回上次切换账户时的账户
-修改用户账号的属性
usermod命令
usermod [选项]... 用户名
-l:更改用户帐号的登录名称
-L:锁定用户账户
-U:解锁用户账户
-u:指定 UID 标记号
-d:指定宿主目录,缺省为 /home/用户名
-e:指定帐号失效时间
-g:指定用户的基本组名(或UID号)
-G:指定用户的附加组名(或GID号)
-M:不为用户建立并初始化宿主目录
-s:指定用户的登录Shell
-删除用户账号
userdel命令
userdel [-r] 用户名 (添加 -r 选项时,表示连用户的宿主目录一并删除)
-用户账号初始配置文件:
文件来源:从/etc/skel目录中复制而来
主要的用户初始配置文件:
用户每次登录时执行
每次进入新的bash环境时执行
用户每次退出登录时执行
组账号文件
-添加组账号
groupadd命令
groupadd [-g GID] 组帐号名
基本组和附加组都在/etc/group里面
-增加/删除组成员
gpasswd命令
用途:设置组帐号密码(极少用)、添加/删除组成员
gpasswd [选项]... 组帐号名
-a:向组内添加一个用户
-d:从组内删除一个用户成员
-M:定义组成员列表,以逗号分隔(会覆盖原组成员)
-删除组账号
groupdel命令
groupdel 组帐号名
-查询账号信息:
id命令
用途:查询用户身份标识
格式:id [用户名]
groups命令
用途:查询用户所属的组
格式:groups [用户名]
finger命令
用途:查询用户帐号的详细信息
格式:finger [用户名]
users、w 、who命令
用途:查询已登录到主机的用户信息
二. 文件和目录的属性:属主、属组、权限
-文件/目录的权限和归属
A. 访问权限
读取r:允许查看文件内容、显示目录列表
写入w:允许修改文件内容,允许在目录中新建、移动、删除文件或子目录
可执行x:允许运行程序、切换目录
B. 归属(所有权)
属主:拥有该文件或目录的用户帐号
属组:拥有该文件或目录的组帐号
ls -l 执行命令后得结果分析
例:
第一个字符:表示文件或目录的类型:
d(目录)
b(块设备文件)
c(字符设备文件)
“-”(普通文件)
“l”(链接文件)
The first 2-4 characters: that the rights owner
The first 5-7 characters: that authority belongs to the group of
The first 8-10 characters: that other human rights
34298: file size in bytes
04-02 00:23: file creation time
install.log: filename
-Linux basic rights into r (4), w (2), x (1)
View the file permissions and ownership / directory
- set the file and directory permissions
chmod command
Format . 1: the chmod [ugoa] [+ - =] [rwx] file or directory ...
Format 2: chmod nnn file or directory ... (recommended)
Common command options
-R: recursively modify new all children of the specified directory
- set file ownership and directory
chown command
Format: chown owner of a file or directory
chown: is a group of files or directories
chown owner: is a group of files or directories
Common command options
-R: recursively modify ownership of all files under the specified directory, subdirectory
- set file permissions mask
Umask can set up a new file, the default permissions of the directory (the default permissions = existing default permissions - permission mask)
Umask view the current permission mask
Umask [permission mask]