首页 > 代码库 > 单元练习

单元练习

ll

<<<第一单元练习题>>>

1.用student用户登陆系统图形界面

2.打开一个bash

3.修改student的密码,把密码更新成"T3st1ngtlme"(主机字母和数字)

[student@desktop 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.显示当前系统时间

[student@desktop Desktop]$ date

Sun Oct  9 11:53:43 EDT 2016

5.显示当前系统时间,显示格式为:"小时:分钟:秒 AM/PM"(AM/PM为上下午标识)

[student@desktop Desktop]$ date +%r

11:54:17 AM

6.显示“/usr/bin/clean-binary-files”的文件类型

[student@desktop Desktop]$ file /usr/bin/clean-binary-files

/usr/bin/clean-binary-files: POSIX shell script, ASCII text executable

7.统计“/usr/bin/clean-binary-files”的文件大小

[student@desktop Desktop]$ wc -c /usr/bin/clean-binary-files

13220 /usr/bin/clean-binary-files

8.用快捷方式在shell中调用已经执行过的第4条命令

[student@desktop Desktop]$ !4

file /usr/bin/clean-binary-files

/usr/bin/clean-binary-files: POSIX shell script, ASCII text executable

9.用快捷方式执行最近一条含有"date"关键字的命令

[student@desktop Desktop]$ date

Sun Oct  9 11:59:51 EDT 2016


<<<第二单元练习>>>

1.用命令和正则表达式按照要求建立文件

*)用一条命令建立12个文件WESTOS_classX_linuxY(X的数值范围为1-2,Y的数值范围为1-6)

*)这些文件都包含在root用户桌面的study目录中

[root@desktop Desktop]# mkdir study

[root@desktop Desktop]# touch study/WESTOS_class{1,2}_linux{1..6}

*)用一条命令建立8个文件redhat_versionX(x的范围为1-8)

*)redhat_virsionX这些文件都包含在/mnt目录中的VERSION中

[root@desktop Desktop]# cd /mnt/

[root@desktop mnt]# mkdir VERSION

[root@desktop mnt]# touch VERSION/redhat_virsion{1..8}

2.管理刚才信建立的文件要求如下

*)用一条命令把redhat_versionX中的带有奇数的文件复制到桌面的SINGLE中

[root@desktop mnt]# cd /root/Desktop/

[root@desktop Desktop]# mkdir SINGLE

[root@desktop Desktop]# cp /mnt/VERSION/redhat_virsion{1,3,5,7} SINGLE

*)用一条命令把redhat_versionX中的带偶数数的文件复制到/DOUBLE中

[root@desktop Desktop]# cp /mnt/VERSION/redhat_virsion{2,4,6,8} /DOUBLE

*)用一条命令把WESTOS_classX_linuxY中class1的文件一动到当前用户桌面的CLASS1中

[root@desktop Desktop]# mkdir CLASS1

[root@desktop Desktop]# mv study/WESTOS_class1_linux{1..6} CLASS1

*)用一条命令把WESTOS_classX_linuxY中class2的文件一动到当前用户桌面的CLASS2中

[root@desktop Desktop]# mkdir CLASS2

[root@desktop Desktop]# mv study/WESTOS_class2_linux{1..6} CLASS2

3.备份/etc目录中所有带有名字带有数字并且以.conf结尾的文件到桌面上的confdir中

[root@desktop Desktop]# mkdir confdir

[root@desktop Desktop]# cp -r /etc/*[[:digit:]].conf confdir

[root@desktop Desktop]# ls confdir

krb5.conf

5.删掉刚才建立或者备份的所有文件

[root@desktop Desktop]# rm -rf confdir

 

<<<第四单元练习>>>

1.在student用户下执行find /etc -name passwd 命令,并管理其输出要求如下:

        * 显示所有正确输出,屏蔽错误输出

[student@desktop ~]$ 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

[student@desktop ~]$ logout

[root@desktop Desktop]# chmod 777 /mnt/

[root@desktop Desktop]# su - student

Last login: Mon Oct 10 00:51:59 EDT 2016 on pts/0

[student@desktop ~]$ find /etc -name passwd > /mnt/find.out

[student@desktop ~]$ cat /mnt/find.out

/etc/passwd

/etc/pam.d/passwd

[student@desktop ~]$ find /etc -name passwd 2> /mnt/find.err

/etc/passwd

/etc/pam.d/passwd

[student@desktop ~]$ 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文件,并且保存所有输出到此文件中

[student@desktop ~]$ find /etc -name passwd &> /mnt/file.all

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

[student@desktop ~]$ find /etc -name passwd &>> /mnt/file.all

        * 屏蔽此命令的所有输出

[student@desktop ~]$ find /etc -name passwd file

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

[student@desktop ~]$ 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中,屏蔽错误输出

[student@desktop ~]$ 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中的空格,但要保持文件中原有的内容








 



单元练习