Showing posts with label chmod. Show all posts
Showing posts with label chmod. Show all posts

Friday, October 14, 2011

chmod for files (directories) all by one

~/chmod.sh.html
 1 #Set private
 2 chmod -R go-rwx ~
 3 
 4 #Set all regular files 600
 5 find ~/ -type f -exec chmod 600 {} \;
 6 
 7 #Set all directories 700
 8 find ~/ -type d -exec chmod 700 {} \;
 9 
10 #Set all un-executable files 600
11 find ~/ ! -executable -exec chmod 600 {} \;
12 
13 #Set all executable files 700
14 find ~/ -executable -exec chmod 700 {} \;

Monday, October 10, 2011

Linux批量修改设置文件/文件夹权限

用Linux服务器的时候,最麻烦的莫过于权限的设置。
一种可视化的方法就是通过Winscp一个一个文件夹设置,但是速度太慢了。
其实SSH中可以用递归的方法实现批量修改文件或文件夹权限(chmod)操作:
先进入目录,举例为www
cd /www
然后递归设置文件夹(目录)权限为777
find -type d -exec chmod 777 {} \;          /一般用这条就可以了
find -type d|xargs chmod 777
随后可以选择设置文件权限为777
find -not -type d -exec chmod 777 {} \;
find -not -type d|xargs chmod 777
上面也是一样,一般只要设置第一行就行了。
但是大饼这里建议各位,有些文件,如config系统配置文件,还是保留为644权限为好。