1. User management (executed under root)
1.1. Add user
useradd -m -g 组 新建用户名
illustrate:
- -m automatically creates the user's home directory
- -g specifies the group the user belongs to. If not added, it will default.
1.2. Set user password
passwd 用户名
illustrate:
- If you are an ordinary user, you can directly use password to modify your account password.
1.3. Delete users
userdel -r 用户名
1.4. Confirm user information
cat /etc/password |grep 用户名
illustrate:
- After creating a new user, the user information is saved in the /etc/password file
2. Group management (executed under root)
2.1. Add group
groupadd 组名
2.2. Delete group
groupdel 组名
2.3. Confirm group information
cat /etc/group
2.4. Recursively modify the group to which a file/directory belongs
chgrp -R 组名
3. View user information
3.1. View user uid information and gid information
id [用户名]
3.2. View the list of all currently logged in users
who
3.3. View the account name of the currently logged in user
whoami
4. usermod sets the user's home group, additional group and login shell
4.1. Modify the user’s main group (gid in passwd)
usermod -g 组名 用户名
4.2. Modify the user’s additional groups
usermod -G 组名 用户名
4.3. Modify user login shell
usermod -s /bin/bash
5. Recursively modify the owner and group of files/directories
chown -R 用户名:组名 文件名/目录名
6. Date and time
date #查看系统时间
cal #查看日历,-y选项可以查看一年的日历
7. The number represented by the file/folder permissions
r w r
4 2 1
8. Disk information
df -h #disk free,显示磁盘信息
du -sh [目录名] #disk usage,显示目录下的文件大小
9. Soft connection
ln -s 被连接的源文件 链接文件 #类似于windows中的快捷方式
illustrate:
- The path to the file generally uses an absolute path.
- If -s is not written, a hard link will be created.