權限修改
先創建目錄
[root@oldboyedu50-lnb ~]# mkdir -p /oldboy
[root@oldboyedu50-lnb ~]# echo ‘hostname‘ >/oldboy/test.sh
[root@oldboyedu50-lnb ~]# cat /oldboy/test.sh
hostname
[oldboy@oldboyedu50-lnb /oldboy]$ ll test.sh
-rw-r--r--. 1 root root 9 Aug 6 12:32 test.sh
1.1.1 oldboy用戶下面測試
[oldboy@oldboyedu50-lnb /oldboy]$ ll test.sh
[oldboy@oldboyedu50-lnb /oldboy]$ cat test.sh
hostname
[oldboy@oldboyedu50-lnb /oldboy]$ echo ‘pwd‘>>test.sh
-bash: test.sh: Permission denied
[oldboy@oldboyedu50-lnb /oldboy]$ /oldboy/test.sh
-bash: /oldboy/test.sh: Permission denied
1.1.2 root用戶下面修改權限 測試w權限
oldboy用戶只有w 權限
[root@oldboyedu50-lnb /oldboy]# chmod u=w test.sh
[root@oldboyedu50-lnb /oldboy]# ll test.sh
--w-r--r--. 1 oldboy oldboy 9 Aug 6 12:32 test.sh
1.2 oldboy用戶下面測試
oldboy@oldboyedu50-lnb /oldboy]$ ll test.sh
--w-r--r--. 1 oldboy oldboy 9 Aug 6 12:32 test.sh
[oldboy@oldboyedu50-lnb /oldboy]$ cat test.sh
[oldboy@oldboyedu50-lnb /oldboy]$ echo ‘pwd‘ >>test.sh
[oldboy@oldboyedu50-lnb /oldboy]$ cat test.sh
cat: test.sh: Permission denied
[oldboy@oldboyedu50-lnb /oldboy]$
[oldboy@oldboyedu50-lnb /oldboy]$ /oldboy/test.sh
-bash: /oldboy/test.sh: Permission denied
root用戶下面修改權限 測試x權限
2.1 oldboy用戶 只有x 權限
[root@oldboyedu50 oldboy]# chmod u=x test.sh
[root@oldboyedu50 oldboy]# ll test.sh
---xr--r--. 1 root root 4 5月 24 08:45 test.sh
2.2 oldboy用戶下面測試
[oldboy@oldboyedu50-lnb /oldboy]$ ll test.sh
---xr--r--. 1 oldboy oldboy 13 Aug 6 12:56 test.sh
[oldboy@oldboyedu50-lnb /oldboy]$ cat test.sh
cat: test.sh: Permission denied
[oldboy@oldboyedu50-lnb /oldboy]$ echo ‘pwd‘ >>test.sh
-bash: test.sh: Permission denied
[oldboy@oldboyedu50-lnb /oldboy]$ /oldboy/test.sh
bash: /oldboy/test.sh: Permission denied
權限修改