Example 1:
1. Check the path after logging in to the system,
[root@localhost ~]# pwd
Then enter the /tmp/ directory,
[root@localhost ~]# cd /tmp
Create two directories test1 and test2,
[root@localhost tmp]# mkdir test1 test2
Create an empty file student in the test1 and test2 directories
[root@localhost tmp]# touch test1/student
[root@localhost tmp]# touch test2/student
2. Create a teacher's directory under the /home/ directory,
[root@localhost ~]# mkdir /home/teacher
Copy test1 to the teacher/ directory,
[root@localhost ~]# cp -r /tmp/test1 /home/teacher
Move test2 to the teacher/ directory;
[root@localhost ~]# mv /tmp/test2 /home/teacher
3. Go to the / directory and find the file named student in the system.
[root@localhost ~]# cd /
[root@localhost /]# find / -name "*student*"
4. Delete the test1 directory under /tmp/.
[root@localhost ~]# rm -rf /tmp/test1
5. Create a test file in the current user's home directory, and then create a soft link with the target pointing to /tmp.
[root@localhost ~]# touch test
[root@localhost ~]# ln -s /root/test /tmp
Example 2:
1. Create/Class Name Directory/My Directory,
[root@localhost ~]# mkdir -p /classname/myname
Enter your name directory and create empty files named 123 and abc in your directory.
[root@localhost ~]# cd /classname/myname
[root@localhost myname]# touch 123 abc
2. Copy my directory to the /tmp directory and list all the details of the /tmp directory
[root@localhost ~]# cp -r /classname/myname /tmp
[root@localhost ~]# ls -l /tmp
3. Find the 123 file in the / directory and save the result to the save file
[root@localhost ~]# find / -name "123" > save
4. Enter the self-built directory and delete all files in the directory
[root@localhost ~]# rm -rf /classname/myname/*
5. Move the class name directory to the /tmp directory and check whether it is successful
[root@localhost ~]# mv /classname /tmp
[root@localhost ~]# ls /tmp | grep classname
6. View the kernel information of the current linux system.
[root@localhost ~]# uname -a
7. Check the IP address information.
[root@localhost ~]# ifconfig ens33
或
[root@localhost ~]# ip addr
8. View memory information.
[root@localhost ~]# cat /proc/meminfo
9. Only count the disk space occupied by the /etc directory.
[root@localhost ~]# du -sh /etc
10. Copy the /etc/passwd file to /root
[root@localhost ~]# cp /etc/passwd /root
11. How many lines are in the statistics /root/passwd file?
[root@localhost ~]# wc -l /root/passwd
12. Use of vi (take /root/passwd as an example)
(1)显示行号
末行模式 <:set nu>
(2)行间跳转,如跳转到15行
末行模式 <:15>
(3)删除一个字符
命令模式 <x 或 del>
(4)一次性删除3行
命令模式 <3dd>
(5)一次性复制3行,粘贴到文件的末尾。
命令模式 <3yy>
命令模式 <G>
命令模式 <p>
(6)从上往下查看所有bin的字符
末行模式 <:bin>
(7)将整篇文档的所有bin替换为333
末行模式 <:% s/bin/333/g>
(8)将第3行到第5行的333替换为444
末行模式 <:3,5 s/333/444/g>
(9)保存并退出。
末行模式 <:wq>