• 企业400电话
  • 网络优化推广
  • AI电话机器人
  • 呼叫中心
  • 全 部 栏 目

    网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    script_tool_for_linux.bash: Linux 环境下的 hosts 一键部署脚本
    POST TIME:2021-10-18 16:17

    Linux 环境下的 hosts 一键部署脚本,由 @lstoars 贡献; @fluviusmagnus 提供增强版本。

    官方网站:https://github.com/racaljk/hosts/tree/master/hosts_tools

    #!/bin/sh
    #
    # script_tool_for_linux
    #
    # Use command: `sudo sh script_tool_for_linux.sh` or
    #    `su -c 'sh script_tool_for_linux.sh'`
    # to update your hosts file.
    #
    # WARNING: the script CAN NOT replace others' hosts rules.
    #   If you have hosts rules provided by others, you may get conflict.
    #
    if [ `id -u` -eq 0 ]; then
     curl -fLo /tmp/fetchedhosts 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts'
     sed -i '/# Copyright (c) 2014/,/# Modified hosts end/d' /etc/hosts
    
     sed -i "s/localhost/`hostname`/g" /tmp/fetchedhosts
    
     cat /tmp/fetchedhosts >> /etc/hosts
     rm -f /tmp/fetchedhosts
    
     echo 'Success.'
    else
     echo 'Permission denied, are you root?'
    fi

    您可能感兴趣的文章:
    • Linux 修改 etc/hosts文件详细介绍
    • linux系统下hosts文件详解及配置
    • 关于linux服务器hosts文件配置详解
    上一篇:用shell脚本监控进程是否存在 不存在则启动的实例
    下一篇:Shell脚本的条件控制和循环语句
  • 相关文章
  • 

    关于我们 | 付款方式 | 荣誉资质 | 业务提交 | 代理合作


    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信