在Windows下面,我們修改hosts文件都知道在哪里,但是在ubuntu系統(tǒng)中呢,還有其它的系統(tǒng),比如安卓手機(jī),或許就沒(méi)那么多的小軟件可供你簡(jiǎn)單的修改了,我們自己來(lái)寫(xiě)個(gè)吧
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/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!" |
以上所述就是本文的全部?jī)?nèi)容了,希望大家能喜歡