一、作業(練習)內容:
1、總結文本編輯工具vim的使用方法;
2、總結文件查找命令find的使用方法;
3、總結bash環境變量的相關內容;
4、總結Linux文件系統上的特殊權限(SUID、SGID、Sticky)的知識點;
5、總結Linux磁盤管理、文件系統相關知識點及其相關命令的使用方法;
6、複製/etc/grub.cfg配置文件至/tmp目錄,用查找替換命令刪除/tmp/grub.cfg文件中的行首的空白字符;
7、複製/etc/rc.d/init.d/functions文件至/tmp目錄,用查找替換命令爲/tmp/functions的每行開頭爲空白字符的行的行首加一個#; 原有空白字符保留;
8、替換/tmp/functions文件中的/etc/sysconfig/init爲/var/log;
9、刪除/tmp/functions文件中所以#開頭,且#後面至少跟了一個空白字符的行的行首#;
10、查找/var目錄屬主爲root,且屬組爲mail的所有文件;
11、查找/usr目錄下不屬於root、bin或hadoop的所有文件;
12、查找/etc目錄下最近一週內其內容修改過,且屬主不爲root或hadoop的所有文件;
13、查找當前系統上沒有屬主或屬組,且最近一週內曾被訪問過的所有文件;
14、查找/etc目錄下大於20k且類型爲普通誰的的所有文件;
15、查找/etc目錄下所有用戶都沒有寫權限的文件;
16、查找/etc目錄下至少有一類用戶沒有執行權限的文件;
17、查找/etc/init.d目錄下,所有用戶都有執行權限,且其它用戶擁有寫權限的文件;
18、讓普通用戶能使用/tmp/cat去查看/etc/shadow文件;
19、創建目錄/test/data,讓某組內普通用戶對其有寫權限,且創建的所有文件的屬組爲目錄所屬的組;此外,每個用戶僅能刪除自己的文件;
第一題:(需補充)
http://huangyisan.blog.51cto.com/6925110/1691863
第二題:(需補充)
http://huangyisan.blog.51cto.com/6925110/1691859
第三題:(需補充)
http://huangyisan.blog.51cto.com/6925110/1691866
第四題:(需補充)
http://huangyisan.blog.51cto.com/6925110/1691869
第五題:(需補充)
http://huangyisan.blog.51cto.com/6925110/1691846
第六題:
:%s/^ \+//g
執行之後:
第七題:
:%s/^ /# /g
執行之後
第八題:
:%s#/etc/sysconfig/init#/var/log#g
執行之後
第九題:
%s@^# \{1,\}@@g
執行後
第十題:
[root@Centos6 ~]# find /var -user root -group mail -ls 130456 4 drwxrwxr-x 2 root mail 4096 Aug 26 04:50 /var/spool/mail
第十一題:
[root@Centos6 ~]# find /usr/ -not \( -user root -o -user bin -o -user hadoop -o -group root -o -group bin -o -group hadoop \) -ls 1957 12 -rwsr-xr-x 1 abrt abrt 10296 Jul 25 00:08 /usr/libexec/abrt-action-install-debuginfo-to-abrt-cache
第十二題:
[root@Centos6 ~]# find /etc/ -mtime -7 -a -not \( -user root -o -user hadoop \) -ls 788088 0 -rw-r--r-- 1 huangyisan huangyisan 0 Aug 26 08:40 /etc/test
第十三題:
[root@Centos6 ~]# find / -nouser -nogroup -ctime -7 -ls find: `/proc/33911/task/33911/fd/5': No such file or directory find: `/proc/33911/task/33911/fdinfo/5': No such file or directory find: `/proc/33911/fd/5': No such file or directory find: `/proc/33911/fdinfo/5': No such file or directory 788088 0 -rw-r--r-- 1 3002 3002 0 Aug 26 08:40 /etc/test 1441802 4 drwx------ 2 3002 3002 4096 Aug 26 08:41 /home/huangyisan 1441803 4 -rw-r--r-- 1 3002 3002 176 Jul 24 02:55 /home/huangyisan/.bash_profile 1441804 4 -rw-r--r-- 1 3002 3002 124 Jul 24 02:55 /home/huangyisan/.bashrc 1441805 4 -rw-r--r-- 1 3002 3002 18 Jul 24 02:55 /home/huangyisan/.bash_logout
第十四題:
[root@Centos6 etc]# find /etc/ -size +20k -a -type f -exec ls -hl {} \; -rw-r--r--. 1 root root 857K Apr 24 00:07 /etc/pki/tls/certs/ca-bundle.crt -rw-r--r--. 1 root root 1.1M Apr 24 00:07 /etc/pki/tls/certs/ca-bundle.trust.crt -rw-r--r--. 1 root root 189K Apr 24 00:07 /etc/pki/java/cacerts -r--r--r--. 1 root root 194K Aug 26 02:00 /etc/pki/ca-trust/extracted/java/cacerts ... ....
第十五題:
[root@Centos6 etc]# find /etc -not \( -perm /222 \) -ls 787527 4 -r--r--r-- 1 root root 324 Jul 24 00:14 /etc/ld.so.conf.d/kernel-2.6.32-573.el6.x86_64.conf 786738 196 -r--r--r-- 1 root root 198453 Aug 26 02:00 /etc/pki/ca-trust/extracted/java/cacerts 786737 208 -r--r--r-- 1 root root 211626 Aug 26 02:00 /etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem 786735 264 -r--r--r-- 1 root root 266702 Aug 26 02:00 /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem 786736 216 -r--r--r-- 1 root root 217510 Aug 26 02:00 /etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem 786734 352 -r--r--r-- 1 root root 359773 Aug 26 02:00 /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
第十六題:
[root@Centos6 huangyisan]# find ./ \( -perm /111 \) -ls 1441802 4 drwx------ 2 3002 3002 4096 Aug 26 13:56 ./ 1441807 0 -rwxr--r-- 1 root root 0 Aug 26 13:53 ./a1 1441808 0 -rw-r-xr-- 1 root root 0 Aug 26 13:53 ./a2 1441809 0 -rwxr--r-x 1 root root 0 Aug 26 13:53 ./a3 1441806 0 -rwxrwxrwx 1 root root 0 Aug 26 13:53 ./a
第十七題:
[root@Centos6 huangyisan]# find ./ -perm -111 -a -perm -002 -ls 1441809 0 -rwxr-xrwx 1 root root 0 Aug 26 13:53 ./a3 1441806 0 -rwxrwxrwx 1 root root 0 Aug 26 13:53 ./a
第十八題:
[root@Centos6 huangyisan]# chmod u+s /bin/cat [root@Centos6 huangyisan]# ll /bin/cat -rwsr-xr-x. 1 root root 48568 Oct 15 2014 /bin/cat [root@Centos6 huangyisan]# su huangyisan [huangyisan@Centos6 ~]$ cat /etc/passwd | head -4 root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin
第十九題:
[root@Centos6 huangyisan]# mkdir -p /test/data [root@Centos6 huangyisan]# ll /test/data total 0 [root@Centos6 huangyisan]# ll -d /test/data drwxr-xr-x. 2 root root 4096 Aug 26 14:29 /test/data [root@Centos6 huangyisan]# chmod o+w -R /test/ [root@Centos6 huangyisan]# chmod g+s -R /test/ [root@Centos6 huangyisan]# chmod o+t -R /test/