首页 > 代码库 > 第四单元作业

第四单元作业






登陆student用户

[student@localhost Desktop]$ find /etc -name passwd        ####在/etc目录下按照文件名passwd查找文件####
find:‘/etc/pki/CA/private‘: Permission denied        ####报错:没有进入权力####
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
/etc/passwd        ####正确输出####
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
/etc/pam.d/passwd
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
[student@localhost Desktop]$ find /etc -name passwd 2> /dev/null        ####在/etc目录下按照文件名passwd查找文件,并将错误的输出扔进垃圾箱即/dev/nulll文件####
/etc/passwd        ####屏蔽掉错误输出后,bash中只显示正确输出####
/etc/pam.d/passwd
[student@localhost Desktop]$ find /etc -name passwd > /mnt/find.out        ####在/etc目录下按照文件名passwd查找文件,并将正确的输出到/mnt/find.out文件中####
bash: /mnt/find.out: Permission denied        ####报错:没有进入权力####
[student@localhost Desktop]$ ls -ld /mnt/        ####列出/mnt/目录本身的属性####
drwxr-xr-x. 2 root root 6 Mar 13 2014 /mnt/        ####/mnt/目录对所有用户可以进入目录并查看其文件信息同时还能添加或删除文件,对所有组和其他人只可以进入并查看目录####
[student@localhost Desktop]$ su - root        ####切换到超级用户root####
Password:        ####输入密码(密码无回显)####
[root@localhost Desktop]# chmod o+w /mnt/        ####添加/mnt/目录对其他用户可以添加或删除文件的权限####
[root@localhost Desktop]# ls -ld /mnt/        
drwxr-xrwx. 2 root root 6 Mar 13 2014 /mnt/        ####修改后的属性####
[root@localhost Desktop]# logout        ####退出用户登陆####
[student@localhost Desktop]$ find /etc -name passwd > /mnt/find.out        ####在/etc目录下按照文件名passwd查找文件,并将正确的输出到/mnt/find.out中####
find:‘/etc/pki/CA/private‘: Permission denied        ####正确的输出到文件,bash显示剩下的错误的####
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
[student@localhost Desktop]$ find /etc -name passwd 2> /mnt/find.err        ####在/etc目录下按照文件名passwd文件,并将错误的输出到/mnt/find.err####
/etc/passwd        ####错误的输出到文件,bash显示剩下的正确的####
/etc/pam.d/passwd
[student@localhost Desktop]$ find /etc -name passwd &> /mnt/find.all        ####在/etc目录下按照文件名passwd文件,并全部输出到/mnt/find.all####
[student@localhost Desktop]$ cat /mnt/find.all        ####查看/mnt/find.all文件内容####
find:‘/etc/pki/CA/private‘: Permission denied
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
/etc/passwd
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
/etc/pam.d/passwd
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
[student@localhost Desktop]$ find /etc -name passwd &>> /mnt/find.all        ####在/etc/目录下按照文件名passwd查找文件并全部追加到/mnt/find.all中####
[student@localhost Desktop]$ cat /mnt/find.all
find:‘/etc/pki/CA/private‘: Permission denied
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
/etc/passwd
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
/etc/pam.d/passwd
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
find:‘/etc/pki/CA/private‘: Permission denied
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
/etc/passwd
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
/etc/pam.d/passwd
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
[student@localhost Desktop]$ find /etc -name passwd &> /dev/null        ####在/etc目录中按照文件名passwd查找文件,并将全部输出到垃圾箱####
[student@localhost Desktop]$ find /etc -name passwd 2>&1 | tee file        ####在/etc目录中按照文件名passwd查找文件,并将错误输出的编号变成正确输出的编号,通过管道符将之前的输出复制到桌面的file文件中####
find:‘/etc/pki/CA/private‘: Permission denied
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
/etc/passwd
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
/etc/pam.d/passwd
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
[student@localhost Desktop]$ cat file
find:‘/etc/pki/CA/private‘: Permission denied
find:‘/etc/pki/tsyslog‘: Permission denied
find:‘/etc/audit‘: Permission denied
/etc/passwd
find:‘/etc/polkit-1/rules.d‘: Permission denied
find:‘/etc/polkit-1/localauthority‘: Permission denied
find:‘/etc/grub.d‘: Permission denied
find:‘/etc/selinux/targeted/modules/active‘: Permission denied
/etc/pam.d/passwd
find:‘/etc/lvm/archive‘: Permission denied
find:‘/etc/lvm/backup‘: Permission denied
find:‘/etc/lcm/cache‘: Permission denied
find:‘/etc/dhcp‘: Permission denied
find:‘/etc/firewalld‘: Permission denied
find:‘/etc/audisp‘: Permission denied
find:‘/etc/sudoers.d‘: Permission denied
find:‘/etc/ipsec.d‘: Permission denied
find:‘/etc/libvirt‘: Permission denied
find:‘/etc/cups/ssl‘: Permission denied
[student@localhost Desktop]$ find /etc -name passwd 2> /dev/null |tee /mnt/find.out.1        ####在/etc/目录下按照文件名passwd查找文件,将错误的输出到垃圾箱,通过管道符将(正确的)输出复制到/mnt/find.out.1####
/etc/passwd
/etc/pam.d/passwd
[student@localhost Desktop]$ cat /mnt/find.out.1
/etc/passwd
/etc/pam.d/passwd



登陆超级用户root

[root@localhost Desktop]# grep ich /usr/share/mime/packages/freedesktop.org.xml |tee /root/lines        ####复制/usr/share/mime/packages/freedesktop.org.xml文件中ich所在行,并复制到/root/lines文件中####
[root@localhost Desktop]# vim /root/lines        ####用vim打开/root/lines文件####
在vim的命令模式下输入:%s/\ //g        ####换掉文件中的空格####

第四单元作业