Linux_Modify hosts

Windows users
XP's hosts file in the C drive C:WINDOWS/system32/drivers/etc directory, we use Notepad to open and modify the content inside, add the content to the host file and save it.
ps: Win7, Win8 and other system users
Win7 and later systems involve administrator privileges. You need to run Notepad as an administrator, and then open the Host file to modify

the location of other users' host files:
Android users: First, you must root the phone , and then install the root explorer manager, open and enter the /system/etc directory, long press the host file, and pull the pop-up menu to the bottom, and you will see "open in text editor". Edit and input
Mac OS users: The host location is: /private/etc/hosts
iPhone users: Jailbreak is required, use iFunBox, PP assistant, synchronization assistant, iFile, etc. to access the device file system, backup and modify the file and then overwrite: /etc /hosts
Linux users: modify /etc/hosts

How does the Linux user's /etc/hosts file take effect after
modification? Normally, after modifying /etc/hosts, it should take effect immediately after saving, but sometimes it is not. Use uname -a to see what the hostname is, and then you can know whether the modification takes effect. If not
, the strategies are:
1) Restart the machine
2) Restart the service
      Ubuntu: $sudo /etc/init.d/networking restart
      Gentoo: /etc/init.d/net.eth0 restart
3) Use the hostname command
        as defined by hostname CPU name


ps: hosts are constantly updated ing...
http://blog.my-eclipse.cn/host-google.html

ps:
The relationship between hostname and /etc/hosts
Many people first think of modifying /etc/ when they mention changing hostname hosts file, think that the configuration file of hostname is /etc/hosts. Actually not.
The role of the hosts file is quite like DNS, providing the correspondence between IP addresses and hostnames. The early Internet computers were few, and the hosts file of a single machine was enough to store all networked computers. But with the development of the Internet, this is far from enough. So there is a distributed DNS system. A similar IP address to domain name correspondence is provided by a DNS server. Specifically, you can man hosts.
The Linux system will query the /etc/hosts file before sending a domain name resolution request to the DNS server. If there is a corresponding record in it, the record in the hosts will be used. The /etc/hosts file usually contains this record
127.0.0.1 localhost.localdomain localhost The
hosts file format is one line by one record, which are the IP address hostname aliases, which are separated by blank characters, and aliases are optional.
It is recommended not to modify 127.0.0.1 to localhost, because many applications will use this, such as sendmail, and these programs may not work properly after modification.

Attached to Ubuntu14.04 repo:
### aliyun repo
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326856784&siteId=291194637