【问题标题】:Custom Bash Script [closed]自定义 Bash 脚本 [关闭]
【发布时间】:2013-05-31 14:15:43
【问题描述】:

我没有先设置正确的文件夹就以 root 身份运行它。 不用说它开始重置cpanel服务器根目录下所有文件的权限。

letshost 中的支持人员很快就对我们进行了分类 (10/10) 但我想知道是否可以修改这样的脚本以“指定路径” 而不是您当前所在的任何文件夹。

find . -type d -print -exec chmod 750 {} \; && find . -type d -print -exec chown user:nobody {} \; && find . -type f -print -exec chmod 644 {} \; && find . -type f -print -exec chown user:user {} \;

有人知道怎么做吗?

【问题讨论】:

    标签: bash chown


    【解决方案1】:

    find 的第一个命令行参数是您搜索的路径。在这种情况下,它是.,即当前工作目录。如果您将其更改为不同的路径,则会改为搜索该路径:

    find $YOUR_DIRECTORY -type d .....
    

    【讨论】:

    • 对所以找到 $home/user/public_html/ -type d ...
    • 如果你定义了$home,是的。
    • 如何准确定义 $home?
    • 定义所有shell变量的方式相同:home=/write/your/path/here如果不给shell变量赋值,它将扩展为空字符串,因此find $home/user/public将执行find /user/public
    【解决方案2】:

    您可以将. 替换为适当的字符串,例如"$1" 用于第一个参数或"${1-.}" 表示“第一个参数(如果存在),否则为.”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 2012-03-29
      相关资源
      最近更新 更多