您现在的位置是:网站首页> 编程资料编程资料
script_tool_for_linux.bash: Linux 环境下的 hosts 一键部署脚本_linux shell_
2023-05-26
354人已围观
简介 script_tool_for_linux.bash: Linux 环境下的 hosts 一键部署脚本_linux shell_
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
相关内容
- 用shell脚本监控进程是否存在 不存在则启动的实例_linux shell_
- SHELL脚本监控JAVA进程的代码_linux shell_
- 关于shell的几个不为人知却十分有用的命令分享_linux shell_
- shell 随机从文件中抽取若干行的实现方法_linux shell_
- awk 九九乘法表 shell实现代码_linux shell_
- Linux服务器硬件运行状态及故障邮件提醒的监控脚本分享_linux shell_
- Linux下Shell编程快捷键大全(日常整理)_linux shell_
- Shell if中的正则表达式使用详解_linux shell_
- SED单行脚本快速参考中文版(Unix 流编辑器)_linux shell_
- CCKiller:Linux轻量级CC攻击防御工具,秒级检查、自动拉黑和释放_linux shell_
