(k8s-king)实战案例——搜索命令的使用
【摘要】 3.5 实战案例——搜索命令的使用搜索命令的使用-实操.mp4(1)将/etc/passwd下有出现root的行取出[root@localhost ~]# grep root /etc/passwdroot:x:0:0:root:/root:/bin/bashoperator:x:11:0:operator:/root:/sbin/nologin(2)将/etc/passwd下没有出现roo...
3.5 实战案例——搜索命令的使用
(1)将/etc/passwd下有出现root的行取出
[root@localhost ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
(2)将/etc/passwd下没有出现root和nologin的行取出
[root@localhost ~]# grep -v root /etc/passwd | grep -v nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
yyx:x:1000:1000:yyx:/home/yyx:/bin/bash
(3)在根目录下查找文件名是yum.conf的文件
[root@localhost ~]# find / -name yum.conf
/etc/yum.conf
(4)查找权限值为644 (-rw-r–r--)的文件,结果如图3-1所示。
[root@localhost ~]# touch a.txt test.txt //创建俩个txt文件
[root@localhost ~]# find . -perm 644 -print //查询
图3-1 根据权限查找文件
(5)查找根目录下test.txt文件并输入到a.txt中,输入命令:
[root@localhost ~]# find -name test.txt -print > a.txt
[root@localhost ~]# echo "what is your name ?" >> test.txt
[root@localhost ~]# find -name test.txt -print > a.txt
[root@localhost ~]# ls
a.txt test.txt
[root@localhost ~]# cat a.txt
./test.txt
查看目录文件结果如图3-2所示。
图3-2 查找并输出到新文件
(6)在 ps aux的结果中查找test,使用ps aux | grep "test"命令。结果如图3-3所示。
[root@localhost ~]# ps aux | grep "test"
图3-3 查找
(7)将输出到显示器的“hello word”重定向输出到test.txt文件中
[root@localhost ~]# echo "hello word" >> ./test.txt
[root@localhost ~]# ls
a.txt test.txt
[root@localhost ~]# cat test.txt
what is your name?
hello word
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)