day08 作业
1.使用linux实现命令别名,实现如下效果,思考,如何生成la命令。
[root@yuanlai-0224 ~]# la /var/log/
total 1.9M
drwxr-xr-x. 6 root root 4.0K Mar 6 03:33 .
drwxr-xr-x. 19 root root 267 Feb 26 03:27 ..
drwxr-xr-x. 2 root root 204 Feb 26 03:01 anaconda
drwx------. 2 root root 23 Feb 26 03:27 audit
-rw-------. 1 root root 0 Mar 3 05:49 boot.log
-rw-------. 1 root root 19K Feb 27 13:25 boot.log-20220227
我的作答
[root@linux-yzk ~]# alias ls='ls -la'
[root@linux-yzk ~]# ls
总用量 36736
dr-xr-x---. 19 root root 4096 2月 28 14:19 .
dr-xr-xr-x. 17 root root 224 12月 17 00:09 ..
-rw-r--r--. 1 root root 18780160 2月 28 11:56 all_robots.tar
-rw-------. 1 root root 3132 2月 27 23:23 .bash_history
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
drwx------. 15 root root 4096 12月 16 20:26 .cache
drwxr-xr-x. 14 root root 4096 1月 9 09:55 .config
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
2.删除/my_data目录下所有数据。
rm -rf /my_data/*
3.linux校验文件唯一值?简述用法。
用MD5的值来校验
4.Linux和windows如何互相传递文件?演示其用法。
一般用[root@server ~]#yum install -y lrzsz
5.linux如何下载网络资源?
一般有二个命令 wget
curl
6.练习vim编辑器,完成如下操作。(图文解释流程+代码实践)
- vim有几种工作模式?
- vim模式之间如何切换?
1.用vim 打开文件就是普通的模式2.编辑模式 按 a, i ,o3.命令模式 按 : 或者 /4.ctl + c
- vim如何快速定位到文件第68行?
第一种方法 :68第二种方法 68G
- vim如何快速进入文件底部?
普通模式 G
- vim如何删除光标所在行?
在普通模式下 dd
- vim如何进入编辑模式?有几种指令?
i,o,a
- 如何使用vim另存为文件?
:w /test/hello
- vim如何从编辑模式,进入底线模式?
按 : 或者 /
7.有如下测试数据,完成vim实践练习。
文本数据:
I have a dog. My dog name is DuDu. DuDu is 9 years. DuDu is fat. It wears a white coat. DuDu has two big eyes and two small ears. It has one short mouth. My dog is smart. I like my dog. Do you like it? 我有一只狗。我的狗的名字叫嘟嘟。嘟嘟是9年。嘟嘟胖。它穿着一件白色外套。嘟嘟有两个大眼睛和两个小耳朵。它有一个短嘴。我的狗是聪明的。我喜欢我的狗。你喜欢吗?
实践题
根据题目完成实践,依次截图每一题的结果。
1.将上述文本内容,写入到/test_vim/learn_vim.txt
have a dog. My dog name is DuDu. DuDu is 9 years. DuDu is fat. It wears a white coat. DuDu has two big eyes and two small ears. It has one short mouth. My dog is smart. I like my dog. Do you like it? 我有一只狗。我的狗的名字叫嘟嘟。嘟嘟是9年。嘟嘟胖。它穿着一件白色外套。嘟嘟有两个大眼睛和>两个小耳朵。它有一个短嘴。我的狗是聪明的。我喜欢我的狗。你喜欢吗?
~ -- 插入 (粘帖) --
2.如何显示该文件行号?
1 have a dog. My dog name is DuDu. DuDu is 9 years. DuDu is fat. It wears a white coat. DuDu has two big eyes and two small ears. It has one short mouth. My dog is smart. I like my dog. Do you like it?2 3 4 我有一只狗。我的狗的名字叫嘟嘟。嘟嘟是9年。嘟嘟胖。它穿着一件白色外套。嘟嘟有两个大眼> 睛和两个小耳朵。它有一个短嘴。我的狗是聪明的。我喜欢我的狗。你喜欢吗?
~
~
:set nu
3.如何快速移动光标到行首?以及行尾?
首行 按0
尾行 按$
4.如何移动光标到文档的首行,以及末行?
行首 gg
行尾 G
5.如何复制上述文档,英文行,且复制粘贴到中文行的后面?
yy
1 have a dog. My dog name is DuDu. DuDu is 9 years. DuDu is fat. It wears a white coat. DuDu has two big eyes and two small ears. It has one short mouth. My dog is smart. I like my dog. Do you like it?2 3 4 我有一只狗。我的狗的名字叫嘟嘟。嘟嘟是9年。嘟嘟胖。它穿着一件白色外套。嘟嘟有两个大眼> 睛和两个小耳朵。它有一个短嘴。我的狗是聪明的。我喜欢我的狗。你喜欢吗?5 have a dog. My dog name is DuDu. DuDu is 9 years. DuDu is fat. It wears a white coat. DuDu has two big eyes and two small ears. It has one short mouth. My dog is smart. I like my dog. Do you like it?
6.将中文复制为3份。
yy3
7.撤销刚才的复制动作。
u
8.再恢复刚才的复制动作。
ctl + r
9.删除所有的中文行。
dd
10.将文本内容,另存为到/tmp/learn_vim2.txt
:w /tmp/learn_vim2.txt/:
11.搜索出文本中的所有DuDu关键字,高亮显示
12.如何取消关键字高亮显示?
13.现在需要编辑一个python脚本,如何让vim打开颜色高亮?
14.实现单行替换,替换"DuDu"为"大黄"一次。
15.实现单行全局替换,替换所有的"DuDu"为"大黄"。
16.实现全文替换,替换所有的"DuDu"为"狗蛋儿"
17.用粘贴模式,将如下的文本,粘贴到文件中。
apiVersion: apps/v1
kind: Deployment
metadata:name: nginx-deployment
spec:selector:matchLabels:app: nginxreplicas: 2 # tells deployment to run 2 pods matching the templatetemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:1.14.2ports:- containerPort: 80
18.批量添加注释,给17题的配置,加上注释。
19.vim为什么会出现swp文件的错误?
20.如何解决swp文件的错误?分别演示如下情况
-
丢弃、删除swp文件的缓存数据。
-
恢复swp文件的缓存数据。