【问题标题】:modify file content修改文件内容
【发布时间】:2010-12-09 04:03:51
【问题描述】:

我正在使用 bash 脚本在远程机器上安装 lighttpd 服务器。安装后,我需要为服务器配置端口。系统说我无权修改文件/etc/lighttpd/lighttpd.conf,即使我这样做了

sudo echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf

我该如何修改?

【问题讨论】:

    标签: bash file-io ssh lighttpd file-permissions


    【解决方案1】:

    尝试使用chmod更改文件权限

    $ sudo chmod a+x /etc/lighttpd/lighttpd.conf
    

    【讨论】:

    • 嗯...谁需要执行该配置文件?
    【解决方案2】:

    您正在做的是以 root 身份运行 echo,然后尝试以普通用户身份将其输出附加到配置文件。

    你想要的是sudo sh -c 'echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf'

    【讨论】:

      【解决方案3】:

      如果您无权更改文件/etc/lighttpd/lighttpd.conf,请查看lighthttpd 的手册页。如果你可以用不同的配置文件启动它,那么在某处创建一个配置文件并用它启动lighthttpd

      【讨论】:

        【解决方案4】:

        问题是>>右边的位没有在sudo下运行。要么使用 sudo -i 启动超级用户的 root shell 并运行命令,要么只使用前面提到的编辑器。

        【讨论】:

          猜你喜欢
          • 2020-12-08
          • 1970-01-01
          • 1970-01-01
          • 2019-03-04
          • 1970-01-01
          • 1970-01-01
          • 2012-11-24
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多