Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How chmod+find Volume Licensing

Shulou Source: shulou.com Published: 2022-06-01 03:32:37 10月27日 Update

This article will explain in detail how to bulk license chmod+find. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

These two diagrams are directory structure diagrams and permissions diagrams under the test folder. So next I'm going to set all .sh files in the test directory and subdirectories to only executable permissions. After executing the following command, you will find that the permissions of tesh.sh and. / test1/test1.sh have been changed to-x--x--x while others remain the same.

Find. -name "* .sh"-exec chmod 111 {}\; total 0drwxr-xr-x 2 root root 38 Sep 29 10:31 test1drwxr-xr-x 2 root root 6 Sep 29 10:13 test2-rw-r--r-- 1 root root 0 Sep 29 10:38 test.bash---x--x--x 1 root root 0 Sep 29 10:22 test.sh-rw-r--r-- 1 root root 0 Sep 29 10:38 test.tx

Find. -name "* .sh" and find. The difference between-name *. Sh is that it is missing a double quotation mark, and the result is one recursive and one non-recursive.

Some people will say that chmod can be recursive if it has a-R parameter. However, chmod-R implements indiscriminate attacks, so it is not applicable, and the above authorization commands can also be written like this. The effect is the same.

Change the file. Txt to executive permission

[root@oracle1 test] # chmod 111`find. -name "* .txt" `[root@oracle1 test] # lltotal 0d--x--x--x 2 root root 38 Sep 29 10:31 test1d--x--x--x 2 root root 6 Sep 29 10:13 test2-rw-r--r-- 1 root root 0 Sep 29 10:38 test.bash---x--x--x 1 root root 0 Sep 29 10:22 test.sh---x--x--x 1 root root 0 Sep 29 10:38 test.txt

So here comes the problem again. What if there is only the difference between a file and a folder in a directory? OK, at this point you can use the-type parameter of the find command. Type is followed by d for directories and f for files.

Set the file to only executable permissions

[root@oracle1 test] # chmod 111`find. -type f` [root@oracle1 test] # lltotal 0d--x--x--x 2 root root 38 Sep 29 10:31 test1d--x--x--x 2 root root 6 Sep 29 10:13 test2---x--x--x 1 root root 0 Sep 29 10:38 test.bash---x--x--x 1 root root 0 Sep 29 10:22 test.sh---x--x--x 1 root root 0 Sep 29 10:38 test.txt

Set the directory to 755 permissions

[root@oracle1 test] # chmod 755`find. -type d` [root@oracle1 test] # lltotal 0drwxr-xr-x 2 root root 38 Sep 29 10:31 test1drwxr-xr-x 2 root root 6 Sep 29 10:13 test2---x--x--x 1 root root 0 Sep 29 10:38 test.bash---x--x--x 1 root root 0 Sep 29 10:22 test.sh---x--x--x 1 root root 0 Sep 29 10:38 test.txt on "how chmod+find bulk Licensing" ends here Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Files permissions directories only commands articles recursion representatives parameters folders more good practical next content subitems subdirectories that is differences quotation marks Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Xiaomi Redmi MariaDB