当前位置: 首页 > web >正文

五一作业-day01

文章目录

  • 1. 每日基操
  • 2. 模拟故障
    • 2.1 **File exist 文件已经存在**
    • 2.2 **No such file or directory 没有这个文件或目录(这个东西不存在)**
    • 2.3 **command not found 命令找不到(没有这个命令)**
    • 2.4 **invalid option 无效的参数(不可用的参数)**
    • 2.5 **overwrite 覆盖**
  • 3. 习题
  • 4. **进阶习题**

1. 每日基操

[ ] 创建一个空文件,批量创建多个空文件。
[ ] 创建一个目录,创建多个目录,创建多层目录。
[ ] 编辑文件内容vim快捷键。
[ ] 移动到第一行,最后一行,某一行。
[ ] 复制,删除,粘贴操作。
[ ] 在文件中查找内容,显示文件行号。
[ ] 查看文件内容,对文件内容进行过滤。
[ ] 显示目录内容,显示目录本身属性。
[ ] 可以通过ls查看文件或目录的属性信息。
[ ] 删除文件,删除目录。
[ ] 对文件或目录进行重命名。


[root@oldboy99-Kylin ~/oldboy]# touch test.txt
[root@oldboy99-Kylin ~/oldboy]# touch test{01..05}.txt
[root@oldboy99-Kylin ~/oldboy]# ls
02-【awk练习文件】access-服务的访问日志-v3.zip  test01.txt
access.log                                      test02.txt
awk.txt                                         test03.txt
secure-20161219                                 test04.txt
secure-20161219.zip                             test05.txt
sort2.txt                                       test.txt
sort.txt                                        uniq.txt
[root@oldboy99-Kylin ~/oldboy]# mkdir test
[root@oldboy99-Kylin ~/oldboy]# mkdir test{01..05}
[root@oldboy99-Kylin ~/oldboy]# mkdir test/test01/test02 -p
[root@oldboy99-Kylin ~/oldboy]# tree
.
├── 02-【awk练习文件】access-服务的访问日志-v3.zip
├── access.log
├── awk.txt
├── secure-20161219
├── secure-20161219.zip
├── sort2.txt
├── sort.txt
├── test
│   └── test01
│       └── test02
├── test01
├── test01.txt
├── test02
├── test02.txt
├── test03
├── test03.txt
├── test04
├── test04.txt
├── test05
├── test05.txt
├── test.txt
└── uniq.txt8 directories, 14 files
[root@oldboy99-Kylin ~/oldboy]# vim test.txt 
[root@oldboy99-Kylin ~/oldboy]# vim test.txt 
[root@oldboy99-Kylin ~/oldboy]# grep 'sunkexu' -i test.txt
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
# SunKexu  
[root@oldboy99-Kylin ~/oldboy]# grep 'sunkexu' -i test.txt -n
3:# SunKexu  
4:# SunKexu  
5:# SunKexu  
6:# SunKexu  
7:# SunKexu  
8:# SunKexu  
9:# SunKexu  
19:# SunKexu  
20:# SunKexu  
21:# SunKexu  
22:# SunKexu  
23:# SunKexu  
[root@oldboy99-Kylin ~/oldboy]# ll ./
总用量 113168
-rw-r--r-- 1 root root  3765999  430 10:48 02-【awk练习文件】access-服务的访问日志-v3.zip
-rw-r--r-- 1 root root 58817074  921  2017 access.log
-rw-r--r-- 1 root root      137  430 10:19 awk.txt
-rw-r--r-- 1 root root 51053780  215  2017 secure-20161219
-rw-r--r-- 1 root root  2218287  430 10:48 secure-20161219.zip
-rw-r--r-- 1 root root       46  430 14:13 sort2.txt
-rw-r--r-- 1 root root       41  430 14:02 sort.txt
drwxr-xr-x 3 root root       20  54 12:18 test
drwxr-xr-x 2 root root        6  54 12:18 test01
-rw-r--r-- 1 root root        0  54 12:17 test01.txt
drwxr-xr-x 2 root root        6  54 12:18 test02
-rw-r--r-- 1 root root        0  54 12:17 test02.txt
drwxr-xr-x 2 root root        6  54 12:18 test03
-rw-r--r-- 1 root root        0  54 12:17 test03.txt
drwxr-xr-x 2 root root        6  54 12:18 test04
-rw-r--r-- 1 root root        0  54 12:17 test04.txt
drwxr-xr-x 2 root root        6  54 12:18 test05
-rw-r--r-- 1 root root        0  54 12:17 test05.txt
-rw-r--r-- 1 root root     1133  54 12:24 test.txt
-rw-r--r-- 1 root root      209  430 14:41 uniq.txt
[root@oldboy99-Kylin ~/oldboy]# ll ./ -d
drwxr-xr-x 8 root root 4096  54 12:24 ./
[root@oldboy99-Kylin ~/oldboy]# ll ./ 
总用量 113168
-rw-r--r-- 1 root root  3765999  430 10:48 02-【awk练习文件】access-服务的访问日志-v3.zip
-rw-r--r-- 1 root root 58817074  921  2017 access.log
-rw-r--r-- 1 root root      137  430 10:19 awk.txt
-rw-r--r-- 1 root root 51053780  215  2017 secure-20161219
-rw-r--r-- 1 root root  2218287  430 10:48 secure-20161219.zip
-rw-r--r-- 1 root root       46  430 14:13 sort2.txt
-rw-r--r-- 1 root root       41  430 14:02 sort.txt
drwxr-xr-x 3 root root       20  54 12:18 test
drwxr-xr-x 2 root root        6  54 12:18 test01
-rw-r--r-- 1 root root        0  54 12:17 test01.txt
drwxr-xr-x 2 root root        6  54 12:18 test02
-rw-r--r-- 1 root root        0  54 12:17 test02.txt
drwxr-xr-x 2 root root        6  54 12:18 test03
-rw-r--r-- 1 root root        0  54 12:17 test03.txt
drwxr-xr-x 2 root root        6  54 12:18 test04
-rw-r--r-- 1 root root        0  54 12:17 test04.txt
drwxr-xr-x 2 root root        6  54 12:18 test05
-rw-r--r-- 1 root root        0  54 12:17 test05.txt
-rw-r--r-- 1 root root     1133  54 12:24 test.txt
-rw-r--r-- 1 root root      209  430 14:41 uniq.txt
[root@oldboy99-Kylin ~/oldboy]# cd ..
[root@oldboy99-Kylin ~]# ll -d ./oldboy/
drwxr-xr-x 8 root root 4096  54 12:24 ./oldboy/
[root@oldboy99-Kylin ~]# ls ./oldboy/
02-【awk练习文件】access-服务的访问日志-v3.zip  test02
access.log                                      test02.txt
awk.txt                                         test03
secure-20161219                                 test03.txt
secure-20161219.zip                             test04
sort2.txt                                       test04.txt
sort.txt                                        test05
test                                            test05.txt
test01                                          test.txt
test01.txt                                      uniq.txt
[root@oldboy99-Kylin ~]# ls ./oldboy/ -a
.                                               test01.txt
..                                              test02
02-【awk练习文件】access-服务的访问日志-v3.zip  test02.txt
access.log                                      test03
awk.txt                                         test03.txt
secure-20161219                                 test04
secure-20161219.zip                             test04.txt
sort2.txt                                       test05
sort.txt                                        test05.txt
test                                            test.txt
test01                                          uniq.txt
[root@oldboy99-Kylin ~]# ls ./oldboy/ -al
总用量 113172
drwxr-xr-x 8 root root     4096  54 12:24 .
dr-xr-x--- 4 root root      328  54 12:24 ..
-rw-r--r-- 1 root root  3765999  430 10:48 02-【awk练习文件】access-服务的访问日志-v3.zip
-rw-r--r-- 1 root root 58817074  921  2017 access.log
-rw-r--r-- 1 root root      137  430 10:19 awk.txt
-rw-r--r-- 1 root root 51053780  215  2017 secure-20161219
-rw-r--r-- 1 root root  2218287  430 10:48 secure-20161219.zip
-rw-r--r-- 1 root root       46  430 14:13 sort2.txt
-rw-r--r-- 1 root root       41  430 14:02 sort.txt
drwxr-xr-x 3 root root       20  54 12:18 test
drwxr-xr-x 2 root root        6  54 12:18 test01
-rw-r--r-- 1 root root        0  54 12:17 test01.txt
drwxr-xr-x 2 root root        6  54 12:18 test02
-rw-r--r-- 1 root root        0  54 12:17 test02.txt
drwxr-xr-x 2 root root        6  54 12:18 test03
-rw-r--r-- 1 root root        0  54 12:17 test03.txt
drwxr-xr-x 2 root root        6  54 12:18 test04
-rw-r--r-- 1 root root        0  54 12:17 test04.txt
drwxr-xr-x 2 root root        6  54 12:18 test05
-rw-r--r-- 1 root root        0  54 12:17 test05.txt
-rw-r--r-- 1 root root     1133  54 12:24 test.txt
-rw-r--r-- 1 root root      209  430 14:41 uniq.txt
[root@oldboy99-Kylin ~]# cd oldboy/
[root@oldboy99-Kylin ~/oldboy]# ls
02-【awk练习文件】access-服务的访问日志-v3.zip  test02
access.log                                      test02.txt
awk.txt                                         test03
secure-20161219                                 test03.txt
secure-20161219.zip                             test04
sort2.txt                                       test04.txt
sort.txt                                        test05
test                                            test05.txt
test01                                          test.txt
test01.txt                                      uniq.txt
[root@oldboy99-Kylin ~/oldboy]# rm -f test{01..05}.txt 
[root@oldboy99-Kylin ~/oldboy]# ls
02-【awk练习文件】access-服务的访问日志-v3.zip  test01
access.log                                      test02
awk.txt                                         test03
secure-20161219                                 test04
secure-20161219.zip                             test05
sort2.txt                                       test.txt
sort.txt                                        uniq.txt
test
[root@oldboy99-Kylin ~/oldboy]# rm -rf test{01..05}
[root@oldboy99-Kylin ~/oldboy]# ls
02-【awk练习文件】access-服务的访问日志-v3.zip  sort2.txt
access.log                                      sort.txt
awk.txt                                         test
secure-20161219                                 test.txt
secure-20161219.zip                             uniq.txt
[root@oldboy99-Kylin ~/oldboy]# mv test test1
[root@oldboy99-Kylin ~/oldboy]# ls
02-【awk练习文件】access-服务的访问日志-v3.zip  sort2.txt
access.log                                      sort.txt
awk.txt                                         test1
secure-20161219                                 test.txt
secure-20161219.zip                             uniq.txt

2. 模拟故障

2.1 File exist 文件已经存在

[root@oldboy99-Kylin ~/oldboy]# mkdir test
[root@oldboy99-Kylin ~/oldboy]# mkdir test
mkdir: 无法创建目录 “test”: 文件已存在

解决方法:

目录名称冲突,创建其他名称的目录。

2.2 No such file or directory 没有这个文件或目录(这个东西不存在)

[root@oldboy99-Kylin ~/oldboy]# cd test02
-bash: cd: test02: 没有那个文件或目录

解决方法:

路径错误。用ls或tree命令查看文件或目录位置,或用history查看历史命令。善用tab键。

2.3 command not found 命令找不到(没有这个命令)

[root@oldboy99-Kylin ~/oldboy]# vin test.txt 
-bash: vin:未找到命令

解决方法:

命令错误。检查命令是否正确,或用yum、apt等查看是否安装该命令程序。也可能是PATH环境配置问题,可以在程序命令路径下执行相关命令,或查看PATH文件。

2.4 invalid option 无效的参数(不可用的参数)

[root@oldboy99-Kylin ~/oldboy]# mkdir -w
mkdir: 不适用的选项 -- w
请尝试执行 "mkdir --help" 来获取更多信息。

解决方法:

命令的选项错误,请仔细查看。

2.5 overwrite 覆盖

[root@oldboy99-Kylin ~]# cp /backup/test ./test 
cp:是否覆盖'./test'

解决方法:

使用cp命令时目标地址有相同名称的文件时会提示该警告。注意路径是否正确,或文件名称是否合理。

3. 习题

 #### 1.1.1.1  用户编写一个文本文件a.txt,想将该文件名称改为txt.a,下面命令可以实现的是 D
cd a.txt txt.a
echo a.txt > txt.a  # 这个命令会创建目标文件,但是内容不对
rm a.txt txt.a
cat a.txt > txt.a
#### 1.1.1.1  设超级用户root当前所在目录为:/usr/local,键入cd命令后,用户当前所在目录为(B) 
/home
/root
/home/root
/usr/local
#### 1.1.1.2  删除文件的命令为 D
mkdir
rmdir
mv
rm
#### 1.1.1.1  Linux有三种查看文件的命令,若希望在查看文件内容过程中可以用光标上下移动来查看文件内容,应使用命令 BC
cat
more
less
vim#### 1.1.1.3  在下列命令中,不能显示文本文件内容的命令是(D )
more
less
tail
join
#### 1.1.1.4  在使用mkdir命令创建新的目录时,在其父目录不存在时先创建父目录的选项是__D___
-m
-d
-f
-p#### 1.1.1.1  在Linux系统中,用来存放系统所需要的配置文件和子目录是(A)
A:/etc
B:/var
C:/root
D:/home#### 1.1.1.1  在linux中,——命令不是针对目录操作的。A
A.ps
B.cd
C.pwd
D. ls
#### 1.2.1.17	(多选)欲把当前目录下的file1.txt复制为file2.txt 正确的命令是( BD)
copy file1.txt file2.txt
cp file1.txt file2.txt
cat file2.txt file1.txt
cat file1.txt > file2.txt#### 1.2.1.20	(多选)Linux创建文件的命令有 (BCDE)
ls
touch
cat
vi/vim
>#### 1.2.1.22	建立一个新文件可以使用的命令为: D
chmod
more
cp
touch

4. 进阶习题

#### 1.1.1.1  下列文件中,包含了主机名到IP地址的映射关系的文件是(B)
A:/etc/HOSTNAME
B:/etc/hosts
C:/etc/resolv.conf
D:/etc/networks#### 1.2.1.19	当内网内没有条件建立dns服务器,又不想用ip访问网站,应配置什么文件   A
hosts
sysconfig
network
hostname
#### 1.2.2.7	Linux修改资源限制是哪个配置文件_/etc/security/limits.conf?修改内核参数是修改哪个配置文件_/etc/sysctl.conf?
#### 1.2.2.14	用户的bash环境变量配置文件是什么?_/etc/profilec_________
#### 1.2.3.4	如何让/etc/passwd 不让任何人操作
chattr +i  /etc/passwd
#### 1.1.1.1  用什么命令来显示当前目录(A
A:echo `pwd`
B:echo pwd   
C:$pwd
D:pwd | echo # echo不读取管道内容
http://www.xdnf.cn/news/3820.html

相关文章:

  • STM32Cube-FreeRTOS任务管理工具函数-笔记
  • 【QT】QT中的网络编程(TCP 和 UDP通信)
  • ES6入门---第二单元 模块五:模块化
  • 【Godot】使用 Shader 实现可配置圆角效果
  • 34.多点求均值的模拟信号抗干扰算法使用注意事项
  • word批量转pdf工具
  • Semaphore的详细源码剖析
  • 函数递归+函数栈帧(简)
  • chili3d调试10 网页元素css node deepwiki 生成圆柱体 生成零件图片
  • Go Web 后台管理系统项目详解
  • 文章记单词 | 第63篇(六级)
  • 解析MCUboot的实现原理和Image结构
  • 【Java学习笔记】作用域
  • FPGA----基于ZYNQ 7020实现EPICS通信系统
  • Linux线程同步机制深度解析:信号量、互斥锁、条件变量与读写锁
  • Python基本语法(lambda表达式)
  • 《Foundation 面板》
  • 数字化时代下,软件测试中的渗透测试是如何保障安全的?
  • 【MySQL】索引(重要)
  • ES6/ES11知识点 续二
  • 项目实战-25年美赛MCM/ICM-基于数学建模与数据可视化的动态系统模型
  • Free Draft Model!Lookahead Decoding加速大语言模型解码新路径
  • HTML01:HTML基本结构
  • AI入门:Prompt提示词写法
  • 字符串匹配 之 KMP算法
  • 【计网】互联网的组成
  • VSCode常用插件推荐
  • 神经网络发展的时间线——积跬步至千里
  • 比较 TensorFlow 和 PyTorch
  • 网狐旗舰大联盟组件源码私测笔记:结构分层、UI重构与本地实操全流程