LINUX 挑战:用户和组管理
wget https://labfile.oss.aliyuncs.com/courses/2585/06.tar.gz
tar -xzf 06.tar.gz
chmod 700 ./06.sh
./06.sh
1
2
3
4
2
3
4
sudo userdel guest2
sudo userdel guest3
sudo userdel guest4
sudo userdel guest5
sudo rm -rf /home/guest2
sudo rm -rf /home/guest3
sudo rm -rf /home/guest4
sudo rm -rf /home/guest5
sudo groupadd guest
mkdir /tmp/tempuser
sudo usermod -u 2000 -g guest -d /tmp/tempuser guest1
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
sudo mkdir /home/vsftpduser
sudo useradd vsftpduser -d /home/vsftpduser -s /usr/sbin/nologin
sudo chown vsftpduser /home/vsftpduser
sudo chgrp vsftpduser /home/vsftpduser
sudo chmod 744 /home/vsftpduser
1
2
3
4
5
6
2
3
4
5
6
sudo useradd mag
sudo useradd dev
sudo useradd test
sudo mkdir /srv/projectx/mag
sudo mkdir /srv/projectx/dev
sudo mkdir /srv/projectx/test
sudo usermod -G dev mag
sudo chown dev:dev /srv/projectx
sudo chmod 751 /srv/projectx
sudo chmod o+rx /srv/projectx/dev
sudo chmod o+rx /srv/projectx/test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
cat /etc/passwd | grep bash | cut -d ':' -f 1,3 > users.txt
1
sudo useradd stu
sudo passwd stu
123456
123456
sudo visudo
:21
# 按i往里写
stu ALL=(shiyanlou:shiyanlou) /bin/touch
# 退出按:wq
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
sudo passwd dev
123456
123456
sudo touch /etc/sudoers.d/dev
sudo chmod 777 /etc/sudoers.d/dev
vim /etc/sudoers.d/dev
# 按i往里写
dev ALL=(root:root) /usr/sbin/useradd
# 退出按:wq
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10