德·摩根定律詳解

一. 德·摩根定律linux

非(A且B) = (非A) 或(非B)centos

非(A 或B) = (非A) 且(非B)bash

1.德·摩根定律確實讓人頭疼,下面爲你們具體詳解ide

 wKiom1ev4O2jRqdwAAAmt-g2BBY621.png

由圖片可知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
相關文章
相關標籤/搜索