用户与组
用户
用户添加—useradd
参数 | 描述 |
---|---|
-d | 指定用户主目录,若目录不存在则使用-m 创建主目录 |
-g | 指定用户某个用户组 |
-G | 指定用户的附加组 |
-s | 指定用户的登录shell(查看系统登录shellchsh -l 或/etc/shells ) |
# 添加登录用户/bin/sh,主目录/home/tom,主组developer,又属于组root
useradd –d /home/tom -m tom -g developer -s /bin/sh -G root
用户管理
用户管理文件/etc/passwd
# 用户名:口令:用户标识号:组标识号:注释性描述:主目录:登录Shell
mysql:x:997:995::/home/mysql:/sbin/nologin
nginx:x:996:994::/home/nginx:/bin/bash
tom:x:1000:1010::/home/tom:/bin/bash
用户密码
添加修改密码passwd 选项 用户名
passwd tom
Old password:******
New password:*******
Re-enter new password:*******
用户权限sudo
修改文件/etc/sudoers
# 给文件添加写权限
chmod u+w /etc/sudoers
# root下添加一行
tom ALL=(ALL) ALL
# 关闭写权限
chmod u-w /etc/sudoers
组
添加组—groupadd
参数 | 描述 |
---|---|
-g | 指定该组的标识号 |
# 添加编号1010的developer组
groupadd -g 1010 developer
组管理
组信息/etc/group
mysql:x:995:
nginx:x:994:
developer:x:1010:
文件压缩
1. tar 打包工具—(tar 参数 压缩名 压缩文件)
- 添加
-c
参数创建压缩包,-f
参数指定文件名
# 打包 test 目录为 test.tar
tar -cf test.tar test/
- 创建
*.tar.gz
,添加-z
参数,使用gzip工具打包
# 打包 test 目录为 test.tar.gz
tar -czf test.tar test/
- 解压
tar -zxvf test.tar.gz
2. unzip 解压缩
# 将 test.zip 解压到当前目录
unzip test.zip
磁盘与目录
1. du
# 查看所有文件大小(以KB显示)
du -h
# 查看当前目录下所有文件的大小(以M显示)
du -sh *
12K ./html
72K ./conf
8.5M ./sbin
8.6M ./
2. df
参数 | 描述 |
---|---|
-h | 常用的容易阅读方式显示 |
-a | 列出所有文件系统 |
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 6.0G 32G 16% /
devtmpfs 911M 0 911M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 380K 920M 1% /run