Create users and groups and Vim operations

Warm reminder: Every day of learning is continuous improvement. Believing in yourself will make you stronger~

1. Create a group admin Create users jack and tom belong to this group (this group is their second group) Create user tony, belong only to admin, their passwords are: qianfeng
groupadd admin
useradd jack
useradd tom
usermod -aG admin jack
usermod -aG admin tom
useradd tony
usermod -G admin tony
passwd jack
qianfeng qianfeng
passwd tom
qianfeng qianfeng
passwd tony
qianfeng qianfeng
2. Copy /etc/fstab to /var/tmp/fstab, the owner and the group are root; anyone Cannot execute; jack can read and write;
cp /etc/fstab /var/tmp/fstab
ll fstab
chmod O+W fstab
3. Create a shared directory /home/admins; the group is admin; the members of the admin group have access to the directory Execution authority, all other users have no authority (except root). Files created in the /home/admins directory will automatically inherit the admin group
mkdir /home/admins
chgrp admin /home/admins
chmod 770 /home/admins
chmod g+s /home/admins
touch mini
ll min
4. Copy /etc/passwd to the /opt directory, and perform the following operation to replace all roots with ROOT
cp /etc/passwd /opt
:%s/root /ROOT/g
Replace the first n of each line with N
: %s/n/N/
Delete lines 1-4
: 1
4dd
5. Create the directory /module. The owner and group are jack admin, respectively. Create 20 files under /module, the file name prefix is ​​?le, (?le1,?le2,?le3 ?le20)
mkdir /module
chown jack /module
chgrp admin /module
cd /module
touch le{1…20}
7. Use the'file attributes', under the settings /module? le2 can only be added but not'delete' and other operations
chattr +a le2
8. Set the user lacp as a user with administrator rights
useradd lacp
vi /etc/sudoers

%wheel ----- lacp

:wq!
9. In the vim editor, please explain the meaning of the following commands: yy, dd, G, i, a, u,
yy Copy
dd Delete
G Move the cursor to the last line
i Edit
at the cursor a Under the cursor One person edited
u to go back and cancel.
10. Find the line
vi /etc/passwd starting with ftp in /etc/passwd
:/^ftp
grep “^ftp” /etc/passwd
11. I hope alice can check /home and In the future, new files created under /home have read, write, and execute permissions ip a
chmod 770 -R /home
chown root.alice /home/ -R
ll -d /home/

12. In the case of using the root user, switch the user to lacp
su-lacp
13. Which two permissions can be set for the root user, and explain their functions.
Prohibit root remote login to prevent others from knowing the root password to log in and destroy
+a
+i
14. How to check your own IP address? (Just write two commands, write more points!!!)
IP a
ifconfig
15. Create a directory named 2001, its group and owner belong to'bk-2002', and all files in this directory inherit the permissions of the directory
mkdir 2001
useradd bk-2002
groupadd bk-2002
chown bk-2002 2001
chgrp bk-2002 2001
chmod g+s 2001
16. Write the shortcut keys for the following commands, move to the beginning of the command line, and delete the command line from the cursor.
gg
dG
17. How to check the detailed attributes of a file? How to view the contents of the file? Say multiple commands
lsattr file name
cat
head
tail
more
less
vi file name
18 Briefly describe the three modes of the vim editor? Remember,
last line mode, command mode, text mode
Insert the command into the bottom line (the last line)
19 Use one command to view the total number of user prompts in the current system | wc -l
cat /etc/passwd | wc
20 Two common hidden permissions, and explain their meaning?
Chattr
a can only be appended, and the source file cannot be modified.
i Cannot perform any operations on the file.
On the basis of the original hidden parameter setting, add or remove the hidden parameter
lsattr to display the file attributes set by the chattr command.

Guess you like

Origin blog.csdn.net/qq_43812373/article/details/109263272