在Windows下面,我们修改hosts文件都知道在哪里,但是在ubuntu系统中呢,还有其它的系统,比如安卓手机,或许就没那么多的小软件可供你简单的修改了,我们自己来写个吧
#!/usr/bin/ruby
#coding=utf-8
require 'open-uri'
url= "http ://raw.github usercontent.com/vokins/simpleu/master/hosts"
begin
open("/etc/hosts","w") do |x|
x.write open(url).read
end
rescue Errno::EACCES
puts "Need root? "
exec "sudo ruby " + $0 + ARGV.join(' ')
end
puts "Write hosts success!"