单元练习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单元练习相关的知识,希望对你有一定的参考价值。
ll
<<<第一单元练习题>>>
1.用student用户登陆系统图形界面
2.打开一个bash
3.修改student的密码,把密码更新成"T3st1ngtlme"(主机字母和数字)
[[email protected] Desktop]$ passwd
Changing password for user student.
Changing password for student.
(current) UNIX password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
4.显示当前系统时间
[[email protected] Desktop]$ date
Sun Oct 9 11:53:43 EDT 2016
5.显示当前系统时间,显示格式为:"小时:分钟:秒 AM/PM"(AM/PM为上下午标识)
[[email protected] Desktop]$ date +%r
11:54:17 AM
6.显示“/usr/bin/clean-binary-files”的文件类型
[[email protected] Desktop]$ file /usr/bin/clean-binary-files
/usr/bin/clean-binary-files: POSIX shell script, ASCII text executable
7.统计“/usr/bin/clean-binary-files”的文件大小
[[email protected] Desktop]$ wc -c /usr/bin/clean-binary-files
13220 /usr/bin/clean-binary-files
8.用快捷方式在shell中调用已经执行过的第4条命令
[[email protected] Desktop]$ !4
file /usr/bin/clean-binary-files
/usr/bin/clean-binary-files: POSIX shell script, ASCII text executable
9.用快捷方式执行最近一条含有"date"关键字的命令
[[email protected] Desktop]$ date
Sun Oct 9 11:59:51 EDT 2016
<<<第二单元练习>>>
1.用命令和正则表达式按照要求建立文件
*)用一条命令建立12个文件WESTOS_classX_linuxY(X的数值范围为1-2,Y的数值范围为1-6)
*)这些文件都包含在root用户桌面的study目录中
[[email protected] Desktop]# mkdir study
[[email protected] Desktop]# touch study/WESTOS_class{1,2}_linux{1..6}
*)用一条命令建立8个文件redhat_versionX(x的范围为1-8)
*)redhat_virsionX这些文件都包含在/mnt目录中的VERSION中
[[email protected] Desktop]# cd /mnt/
[[email protected] mnt]# mkdir VERSION
[[email protected] mnt]# touch VERSION/redhat_virsion{1..8}
2.管理刚才信建立的文件要求如下
*)用一条命令把redhat_versionX中的带有奇数的文件复制到桌面的SINGLE中
[[email protected] mnt]# cd /root/Desktop/
[[email protected] Desktop]# mkdir SINGLE
[[email protected] Desktop]# cp /mnt/VERSION/redhat_virsion{1,3,5,7} SINGLE
*)用一条命令把redhat_versionX中的带偶数数的文件复制到/DOUBLE中
[[email protected] Desktop]# cp /mnt/VERSION/redhat_virsion{2,4,6,8} /DOUBLE
*)用一条命令把WESTOS_classX_linuxY中class1的文件一动到当前用户桌面的CLASS1中
[[email protected] Desktop]# mkdir CLASS1
[[email protected] Desktop]# mv study/WESTOS_class1_linux{1..6} CLASS1
*)用一条命令把WESTOS_classX_linuxY中class2的文件一动到当前用户桌面的CLASS2中
[[email protected] Desktop]# mkdir CLASS2
[[email protected] Desktop]# mv study/WESTOS_class2_linux{1..6} CLASS2
3.备份/etc目录中所有带有名字带有数字并且以.conf结尾的文件到桌面上的confdir中
[[email protected] Desktop]# mkdir confdir
[[email protected] Desktop]# cp -r /etc/*[[:digit:]].conf confdir
[[email protected] Desktop]# ls confdir
krb5.conf
5.删掉刚才建立或者备份的所有文件
[[email protected] Desktop]# rm -rf confdir
<<<第四单元练习>>>
1.在student用户下执行find /etc -name passwd 命令,并管理其输出要求如下:
* 显示所有正确输出,屏蔽错误输出
[[email protected] ~]$ find /etc -name passwd 2> /dev/null
/etc/passwd
/etc/pam.d/passwd
* 保存正确数出到/mnt/find.out,错误数出到/mnt/find.err中
-bash: /mnt/find.out: Permission denied
[[email protected] ~]$ logout
[[email protected] Desktop]# chmod 777 /mnt/
[[email protected] Desktop]# su - student
Last login: Mon Oct 10 00:51:59 EDT 2016 on pts/0
[[email protected] ~]$ find /etc -name passwd > /mnt/find.out
[[email protected] ~]$ cat /mnt/find.out
/etc/passwd
/etc/pam.d/passwd
[[email protected] ~]$ find /etc -name passwd 2> /mnt/find.err
/etc/passwd
/etc/pam.d/passwd
[[email protected] ~]$ cat /mnt/find.err
find: ‘/etc/pki/CA/private’: Permission denied
find: ‘/etc/pki/rsyslog’: 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/lvm/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
* 建立/mnt/find.all文件,并且保存所有输出到此文件中
[[email protected] ~]$ find /etc -name passwd &> /mnt/file.all
* 再次保存所有输出到/mnt/find.all中,并且保持源文件内容
[[email protected] ~]$ find /etc -name passwd &>> /mnt/file.all
* 屏蔽此命令的所有输出
[[email protected] ~]$ find /etc -name passwd file
* 显示此命令的所有输出并保存输出到桌面上的任意文件中
[[email protected] ~]$ find /etc -name passwd
find: ‘/etc/pki/CA/private’: Permission denied
find: ‘/etc/pki/rsyslog’: 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/lvm/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
* 保存正确输出到/mnt/find.out.1中,屏蔽错误输出
[[email protected] ~]$ find /etc -name passwd > /mnt/find.out.1 2> /dev/null
2.处理文件在文件/usr/share/mime/packages/freedesktop.org.xml要求如下:
* 找到此文件中包含ich的行,并保存这些行到/root/lines中
* 用vim替换掉/root/lines中的空格,但要保持文件中原有的内容
以上是关于单元练习的主要内容,如果未能解决你的问题,请参考以下文章