id root
id 普通用户
sudo useradd -u 2021 test2
sudo useradd test3
echo 654321 | passwd -stdin test3
sudo usermod -u 5000 test3
- 修改test3账户的工作组为之前的test1工作组:
sudo usermod -g test1 test3
- 查看test3的信息:cat /etc/passwd
cat /etc/passwd | grep test3
su test3
- 新建账户test4,并设置密码,且为不可登录,尝试登录
echo 123456 | passwd -stdin test4
sudo usermod -s /sbin/nologin test4
- 进入/etc 目录查看详细信息,注意权限项:ls -l
ls -l /etc
-
进入 ~目录新建t1目录在其中新建文件temp1.txt完成如下操作
- 查看temp.txt的权限:ls -l temp1.txt
ls -l ~/t1/temp1.txt
useradd test5
- 查看test5的账户信息:cat /etc/passwd
cat etc/passwd | grep test5
touch temp3.txt
mkdir k1
- 查看temp4隐藏权限: lsattr temp4.txt
lsattr temp4.txt
- 将“hello” 字符串写入到temp4.txt文件中
-
echo “hello” > temp4.txt
- 设置temp4.txt不可删除隐藏权限属性,检查是否可删除:
- 删除temp4.txt隐藏权限:
-
sudo chattr -a temp4.txt
- 尝试删除temp4.txt
rm -f temp4.txt