DAILY DOCDAILY DOC
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
  • linux
  • bash alias
  • chmod
  • linux useful command
  • date
  • extract translation from git diff
  • fail2ban
  • globbing
  • localhost
  • mail
  • memo 内存测试
  • nohup(no hang up)
  • setup env
  • ssh

    • ssh 教程
    • github clone
    • ssh.localhost.run 端口转发
    • ssh 安全
  • systemd service
  • 分析ubuntu系统登录日志文件
  • vpn

    • vpn 教程
    • Algo
    • clashX
    • firezone
    • lantern
    • pac 代理配置
    • Setup vpn
    • shadowsocks
    • VPN
    • VPN 速度优化
    • wireguard cron
    • 修改wireguard端口
  • webhook

chmod

安装 ACL 工具

  1. 更新包列表并安装 acl 包:

    sudo apt update
    sudo apt install acl
    

为现有文件添加执行权限

  1. 为目录下的所有现有文件添加执行权限:

    sudo find /path/to/directory -type f -exec chmod +x {} \;
    

为新添加的文件设置默认执行权限

  1. 为目录设置默认 ACL:

    sudo setfacl -d -m u::rwx /path/to/directory
    sudo setfacl -d -m g::r-x /path/to/directory
    sudo setfacl -d -m o::r-x /path/to/directory
    
  2. 验证设置:

    getfacl /path/to/directory
    

示例

假设你要为 /home/user/scripts 目录下的所有文件添加执行权限,并确保新添加的文件也拥有执行权限,以下是具体的命令:

  1. 安装 acl 工具:

    sudo apt update
    sudo apt install acl
    
  2. 为现有文件添加执行权限:

    sudo find /home/user/scripts -type f -exec chmod +x {} \;
    
  3. 为目录及其内容设置执行权限:

    sudo find /home/user/scripts -type d -exec chmod 755 {} \;
    sudo find /home/user/scripts -type f -exec chmod 755 {} \;
    
  4. 为目录设置默认 ACL:

    sudo setfacl -d -m u::rwx /home/user/scripts
    sudo setfacl -d -m g::r-x /home/user/scripts
    sudo setfacl -d -m o::r-x /home/user/scripts
    
  5. 验证 ACL 设置:

    getfacl /home/user/scripts
    

通过上述步骤,你可以确保目录下的所有现有文件和新添加的文件都具有执行权限。这对于需要自动执行脚本的目录尤其有用。

Last Updated:
Contributors: rosendo
Prev
bash alias
Next
linux useful command