In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
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.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.