linux基础练习题
**
一.作业要求及内容
**
```一.用一条命令建立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}
[[email protected] Desktop]# ls study
WESTOS_class1_linux1 WESTOS_class1_linux5 WESTOS_class2_linux3
WESTOS_class1_linux2 WESTOS_class1_linux6 WESTOS_class2_linux4
WESTOS_class1_linux3 WESTOS_class2_linux1 WESTOS_class2_linux5
WESTOS_class1_linux4 WESTOS_class2_linux2 WESTOS_class2_linux6
``
二.用一条命令建立8个文件redhat_versionX(x的范围为1-8) redhat_virsionX这些文件都包含在/tmp目录中的VERSION中**
[[email protected] Desktop]# cd /tmp/VERSION
[[email protected] VERSION]# touch redhat_version{1..8}
[[email protected] VERSION]# ls
redhat_version1 redhat_version3 redhat_version5 redhat_version7
redhat_version2 redhat_version4 redhat_version6 redhat_version8
管理一:用一条命令把redhat_versionX中的带有奇数的文件复制到桌面的SINGLE中**
[[email protected] VERSION]# cd /home/kiosk/Desktop/
[[email protected] Desktop]# mkdir SINGLE
[[email protected] Desktop]# cd -
/tmp/VERSION
[[email protected] VERSION]# cp redhat_version{1,3,5,7} /home/kiosk/Desktop/SINGLE/
[[email protected] VERSION]# ls /home/kiosk/Desktop/SINGLE/
redhat_version1 redhat_version3 redhat_version5 redhat_version7
管理二:用一条命令把redhat_versionX中的带有偶数的文件复制到/DOUBLE中
[[email protected] ~]# mkdir /DOUBLE
[[email protected] ~]# cd /tmp/VERSION
[[email protected] VERSION]# cp redhat_version{2,4,6,8} /DOUBLE/
[[email protected] VERSION]#
管理三:用一条命令把WESTOS_classX_linuxY中class1的文件移动到当前用户桌面的CLASS1中
[[email protected] VERSION]# cd /home/kiosk/Desktop/
[[email protected] Desktop]# mkdir CLASS1 CLASS2
[[email protected] Desktop]# mv study/WESTOS_class1_linux{1..6} CLASS1
[[email protected] Desktop]# ls CLASS1
WESTOS_class1_linux1 WESTOS_class1_linux3 WESTOS_class1_linux5
WESTOS_class1_linux2 WESTOS_class1_linux4 WESTOS_class1_linux6
管理四:用一条命令把WESTOS_classX_linuxY中class2的文件移动到当前用户桌面的CLASS2中**
[[email protected] Desktop]# mv study/WESTOS_class2_linux{1..6} CLASS2
[[email protected] Desktop]# ls CLASS2
WESTOS_class2_linux1 WESTOS_class2_linux3 WESTOS_class2_linux5
WESTOS_class2_linux2 WESTOS_class2_linux4 WESTOS_class2_linux6
管理五:备份/etc目录中所有带有名字带有数字并且以.conf结尾的文件到桌面上的confdir中
[[email protected] Desktop]# mkdir confdir
[[email protected] Desktop]# cp /etc/*[[:digit:]]*.conf confdir
[[email protected] Desktop]# ls confdir
e2fsck.conf krb5.conf mke2fs.conf
二.作业要求及内容
一.显示当前时间,显示格式为hh:mm:ss,并保存到文件time.txt文件中
[[email protected] Desktop]$ date +%X
04:23:02 PM
[[email protected] Desktop]$ date +%X |tee time.txt
04:23:40 PM
[[email protected] Desktop]$ cat time.txt
04:23:40 PM
[[email protected] Desktop]$ date
Wed Sep 26 16:25:30 CST 2018
二.显示/etc/passwd文件的第15—18行内容
[[email protected] Desktop]$ cat -b /etc/passwd | head -n 18 | tail -n 4
15 systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
16 dbus:x:81:81:System message bus:/:/sbin/nologin
17 polkitd:x:998:996:User for polkitd:/:/sbin/nologin
18 unbound:x:997:994:Unbound DNS resolver:/etc/unbound:/sbin/nologin
三.显示/bin中文件包含大写字母的文件,保存到bin_westos_file.txt文件中,并统计个数显示到屏幕
[[email protected] Desktop]$ ls /bin/*[[:upper:]]* |tee bin_westos_file.txt
/bin/amuFormat.sh
/bin/GET
/bin/HEAD
/bin/Mail
/bin/oLschema2ldif
/bin/POST
/bin/X
/bin/Xorg
/bin/Xvnc
[[email protected] Desktop]$ ls /bin/*[[:upper:]]* |tee bin_westos_file.txt | wc -l
9
四.在student用户下查找/etc 下passwd文件,屏幕错误输出
[[email protected] Desktop]$ find /etc/ -name passwd
五.在student用户下查找/etc下passwd文件,正确输出保存到/tmp/westos.out
错误输出保存到/tmp/westos.err
[[email protected] Desktop]$ find /etc/ -name passwd > /tmp/westos.out
[[email protected] Desktop]$ find /etc/ -name passwd 2> /tmp/westos.err
六.在student用户下查找/etc下passwd文件,显示命令输出并保存输出到/tmp/westos.all中
[[email protected] Desktop]$ find /etc/ -name passwd 2>&1 | tee /tmp/westos.all