Linux练习 二


  • Linux练习 二

在student用户下执行find /etc -name passwd 命令,并管理其输出要求如下:
(1)显示所有正确输出,屏蔽错误输出

find /etc/ -name passwd 2> /dev/null
find /etc/ -name passwd 2> file 

(2)保存正确输出到/mnt/find.out,错误输出到/mnt/find.err中

[student@foundation22 Desktop]$ find /etc/ -name passwd >/mnt/file.out 2> /mnt/file.err 
bash: /mnt/file.out:Persion denied     ##出错,原因是权限不够

[student@foundation22 Desktop]$ su -       ##改权限
Passwd:
[root@foundation22 Desktop]$ chmod 777 /mnt/
[root@foundation22 Desktop]$ chmod ugo+rwx /mnt/   ##给mnt最大的权限
[root@foundation22 Desktop]$ logout
[student@foundation22 Desktop]$ find /etc/ -name passwd >/mnt/file.out 2> /mnt/file.err ##student有了权限翻身农民把歌唱

(3)建立/mnt/find.all文件,并且保存所有输出到此文件中

find /etc/ -name passwd &>/mnt/file.all 

(4)再次保存所有输出到/mnt/find.all中,并且保持源文件内容

find /etc/ -name passwd &>>/mnt/file.all 
            ##即将所有的内容再次保存到file.all里,不覆盖原有的内容

(5)屏蔽此命令的所有输出

find /etc/ -name passwd &>> filee
        ##将所有的输出都保存在指定的文件里就好,因为输出只有一份,如果用户指定了输出存放的位置,那就不会再显示在输出界面上

(6)显示此命令的所有输出并保存输出到桌面上的任意文件中

find /etc/ -name passwd     ##未对输出界面的输出作干涉

(7)保存正确输出到/mnt/find.out.1中,屏蔽错误输出

find /etc/ -name passwd > /mnt/file.out.1 2> /dev/null
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值