当前位置:网站首页>shel自动设置目录权限
shel自动设置目录权限
2022-07-27 03:38:00 【666QAQ】
电脑装了双系统,windows上的文件复制到linux上时,总是会开放所有权限,也就是777。
这样不仅不合理,而且目录会有绿色的前景,看起来非常不舒服
目录较多时,手动设置也比较烦。
如果是个人使用,我们一般将目录设为755,文本文件设为644,就够了。
所以可以通过shell脚本来自动设置。
这里贴一个自己写的简单例子,会递归将目录中的文件夹设为755,文本文件设为644。
#!/bin/bash
YELLOW='\033[0;33m'
LYELLOW='\033[1;33m'
NONE='\033[0m'
usage="${YELLOW}\ Usage: permit <files>.${NONE}\n"
if [ $# -eq 0 ]
then
printf "$usage"
fi
traverse()
{
files=$*
for file in $files
do
if [ -d "$file" ]
then
chmod 755 "$file"
traverse "$file"/*
elif [ -e "$file" ]
then
chmod 644 "$file"
fi
done
}
traverse $*

边栏推荐
- PX4模块设计之十二:High Resolution Timer设计
- 第二轮Okaleido Tiger即将登录Binance NFT,或持续创造销售神绩
- Stm32cubemx learning notes (41) -- eth interface +lwip protocol stack use (DHCP)
- ffmpeg合并视频功能
- What is animation effect? What is the transition effect?
- List Simulation Implementation
- JS to realize page Jump and parameter acquisition and loading
- Subject 3: Jinan Zhangqiu line 3
- Elastic open source community: Developer Recruitment
- Interview question 16.05 factorial mantissa
猜你喜欢

深度剖析 —— 动态内存管理

2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units
![[competition reference] pytorch common code snippet and operation collection](/img/b3/0b91e381e2444dfd222537bf5b8ccf.jpg)
[competition reference] pytorch common code snippet and operation collection

Summer meal | rich people are different from what you think (day 5) + power system power flow simulation (documents and matlab code)

Eureka-服务注册中心

452 pages, 130000 words, the overall solution of modern smart Township Xueliang project 2022 Edition

F - Pre-order and In-order(Atcoder 255)

Okaleido生态核心权益OKA,尽在聚变Mining模式

Learning route from junior programmer to architect + complete version of supporting learning resources

数据库泰斗王珊:努力创新,精心打磨优质的数据库产品
随机推荐
ArrayList与LinkedList区别
【机器学习网络】BP神经网络与深度学习-6 深度神经网络(deep neural Networks DNN)
Navicat将MySQL导出表结构以及字段说明
xxx is not in the sudoers file.This incident will be reported.的解决方法
Introduction to JVM principle
H. 265 web player easyplayer's method of opening video to the public
CloudCompare&PCL 匹配点距离抑制
微信input组件添加清除图标,点击清空不生效
法解析的外部符号 “public: virtual __cdecl nvinfer1::YoloLayerPlugin::~YoloLayerPlugin(void)“ “public: virtua
Detailed explanation of TCP protocol knowledge
【小样本分割】MSANet: Multi-Similarity and Attention Guidance for Boosting Few-Shot Segmentation
Use tag tag in golang structure
STM32基于HAL库的串口接受中断和空闲中断
List Simulation Implementation
webpack打包vue项目添加混淆方式,解决缓存问题
2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units
356 pages, 140000 words, weak current intelligent system of high-end commercial office complex, 2022 Edition
The 100th of the commercial anti counterfeiting series - boring systems and management processes can really be thrown into the trash can - by the way, analyze a dozen useless unity game self-test proj
DINO 论文精度,并解析其模型结构 & DETR 的变体
Maximum nesting depth of parentheses