- 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