0x00
我们都知道 chmod +x 是给所有用户加上执行权限
$ touch myfile
$ ls -l myfile
-rw-r--r-- 1 ronething wheel 0 5 18 20:46 myfile
$ chmod +x myfile && ls -l myfile
-rwxr-xr-x 1 ronething wheel 0 5 18 20:46 myfile
但是 chmod +X 呢
0x01
- 当该文件是目录的时候
chmod +X <dir>
文件就会有可执行权限 这个和 chmod +x 一样
$ ls -ld test
drw-r--r-- 2 ronething wheel 64 5 18 20:32 test
$ chmod +X test
$ ls -ld test
drwxr-xr-x 2 ronething wheel 64 5 18 20:32 test
- 当该文件是普通文件的时候
如果 file 本来没有执行(x)权限(所有用户都没有例如 -rw-r--r--
)
chmod +X <file>
不会对文件产生影响,不会改变文件权限
$ touch myfile
$ ls -l myfile
-rw-r--r-- 1 ronething wheel 0 5 18 20:41 myfile
$ chmod +X myfile && ls -l myfile
# 此时文件权限没有被改变
-rw-r--r-- 1 ronething wheel 0 5 18 20:41 myfile
当 file 有被设定过执行权限 例如 -rwxr--r--
此时执行 chmod +X <file>
文件权限会变成 -rwxr-xr-x
$ chmod 744 myfile && ls -l myfile
-rwxr--r-- 1 ronething wheel 0 5 18 20:41 myfile
$ chmod +X myfile && ls -l myfile
# 文件权限已经被改变
-rwxr-xr-x 1 ronething wheel 0 5 18 20:41 myfile
0x02
封面出处:https://www.pixiv.net/member_illust.php?mode=medium&illust_id=63965953