一. 德·摩根定律linux
非(A且B) = (非A) 或(非B)centos
非(A 或B) = (非A) 且(非B)bash
1.德·摩根定律确实让人头疼,下面为你们具体详解ide
由图片可知post
A=1+2 ;B=2+3 ;c=4centos7
非A=3+4spa
非B=1+4blog
A且B 是同时是A,也同时是B,因此A且B=2图片
A或B 既能够是A,也能够是B,因此A或B=1+2+3get
因此非(A且B) =1+3+4 (非A) 或(非B) =3+4+1
得 非(A且B) = (非A)或(非B)
同理可知 非(A或B) = (非A)且(非B)
(2)在linux中组合条件为
与:-a
或:-o
非:-not, !
德·摩根定律即:
!A -a !B = !(A -o B)
!A -o !B = !(A -a B)
实例:
查找/var目录下最近一周内其内容修改过,同时属主不为root,也不是postfix的文件
[root@centos7 bin]# find /var -mtime -7 -not \( -user root -o -user postfix \) 或者 [root@centos7 bin]# find /var -mtime -7 -not -user root -a -not -user postfix
二. 做业:
一、查找/var目录下属主为root,且属组为mail的全部文件
[root@centos7 bin]# find /var -user root -group mail
二、查找/var目录下不属于root、lp、gdm的全部文件
[root@centos7 bin]# find /var -not \( -user root -o -user lp -o -user gdm \) -ls
三、查找/var目录下最近一周内其内容修改过,同时属主不为root,也不是postfix的文件
[root@centos7 bin]# find /var -mtime -7 -not \( -user root -o -user postfix \)
四、查找当前系统上没有属主或属组,且最近一个周内曾被访问过的文件
[root@centos7 bin]# find / -nouser -nogroup -atime -7 -ls
五、查找/etc目录下大于1M且类型为普通文件的全部文件
[root@centos7 bin]# find /etc -size +1M -type f -ls
六、查找/etc目录下全部用户都没有写权限的文件
[root@centos7 bin]# find /etc/ -not -perm /222 -ls
七、查找/etc目录下至少有一类用户没有执行权限的文件
[root@centos7 bin]# find /etc/ -not -perm -111 -ls
八、查找/etc/init.d目录下,全部用户都有执行权限,且其它用户有写权限的文件
[root@centos7 bin]# find /etc/init.d/ -perm -113