Merge pull request #511 from Vic020/master

Translated
This commit is contained in:
Xingyu.Wang 2013-12-04 05:11:05 -08:00
commit c581ea49ee
3 changed files with 151 additions and 143 deletions

View File

@ -1,3 +1,4 @@
Vic020走起
GCC 4.9 Is Now In Bug-Fixes-Only Stage 3 Mode
================================================================================
[GCC 4.9][1] with [its many new features][2] is aiming for a release in the first half of 2014. As of this morning the GCC code-base will not accept new features as it's under a big-fixing-only flag.

View File

@ -1,143 +0,0 @@
Vic020不好意思的WC
How To Display And Set Hostname in Linux
================================================================================
![](http://linoxide.com/wp-content/uploads/2013/11/hostname-command-linux.jpg)
With more and more computer connected to the network, computer need to have an attribute to make it different to each other. Same as human in the real world, computer also hava an attribute which named hostname.
### What is hostname ###
From its manual page, hostname is used to display the systems DNS name and to display or set its hostname or NIS domain name. So hostname is related to DNS (Domain Name System) or NIS (Network Information System).
### How to display hostname ###
Hostname is a pre-installed command in every Linux distribution. You can display your machine hostname by typing hostname in your console. Heres a sample command and the output :
$ hostname
ubuntu
The above command will tell you that the computer name is **ubuntu**.
### How to set a hostname ###
Hostname is set when you install you Linux at the first time. There is a step in your installation procedure that your Linux will ask you to fill hostname information. However, **you can do it later** if you want.
To set it your hostname, you can use this command :
# hostname dev-machine
$ hostname
dev-machine
You **need to be root** user or equal to set / change your hostname machine. The # sign is indicated that you are a root user. The above command is telling your computer to set its hostname into **dev-machine**. If you dont receive any error message then your hostname is changed. Again, you check it using hostname command to see the result.
Setting hostname using hostname command **is not permanent**. When you reboot your computer, your setting will gone. **To make it permanent**, you must manually edit hostname configuration files.
**On Debian / Ubuntu based Linux**
You will find it in these folders, **/etc/hostname** and **/etc/hosts**.
Heres the content of each files.
**/etc/hostname**
# vi /etc/hostname
dev-machine
**/etc/hosts**
# vi /etc/hosts
127.0.0.1 localhost
127.0.0.1 dev-machine
You will found it **active immediately without restarting** your Linux.
**On RedHat / CentOS based Linux**
You will find it in these folders, **/etc/hosts** and and **/etc/sysconfig/networks**
Heres the content of each files.
**/etc/hosts**
127.0.0.1 localhost.localdomain localhost dev-machine
::localhost 127.0.0.1
/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=dev-machine
### How to display dnsdomainname ###
From hostname definition above, hostname can also display a dnsname for your Linux. If hostname command will display your hostname, then dnsndomainname command will show your domain name. Lets see the sample.
$ dnsdomainname
bris.co.id
On this article, the result of dnsdomainname command is **bris.co.id**.
If you see the result is (**none**), then your machine **is not configured in FQDN** (Fully Qualified Domain Name). Dnsdomainname command will grab information from **/etc/hosts** file. You should configure it in FQDN format. Heres the sample :
**/etc/hosts**
127.0.0.1 localhost.localdomain localhost dev-machine
::localhost 127.0.0.1
192.168.0.104 dev-machine.bris.co.id dev-machine
To display it more detail, you can use parameter **-v**
$ dnsdomainname -v
gethostname()=dev-machine.bris.co.id
Resolving dev-machine.bris.co.id
Result: h_name=dev-machine.bris.co.id
Result: h_aliases=dev-machine
Result: h_addr_list=192.168.0.104
### How to display hostname with more detail information ###
Hostname command comes with some parameters and some aliases such as dnsdomainname command. Heres some parameter that may useful on day-to-day operation. The results of the commands below is based on **/etc/hosts** configuration above
**Display the IP Address**
$ hostname -i
192.168.0.104
**Display the domain**
$ hostname -d
bris.co.id
**Display the the short name**
$ hostname -s
dev-machine
*This command will produce the same result with only typing hostname*
**Display with FQDN format**
$ hostname -f
dev-machine.bris.co.id
**Display with detail information**
All the parameters mentioned above can be **summarized** by the parameter **-v and -d**. Lets take a look the sample
$ hostname -v -d
gethostname()=dev-machine.bris.co.id
Resolving dev-machine.bris.co.id
Result: h_name=dev-machine.bris.co.id
Result: h_aliases=dev-machine
Result: h_addr_list=192.168.0.104
bris.co.id
Feel familiar? Yes, this result is the same with **dnsdomainname -v** command that also mentioned above.
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/display-set-hostname-linux/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -0,0 +1,150 @@
Linux中如何显示和设置Hostname
================================================================================
![](http://linoxide.com/wp-content/uploads/2013/11/hostname-command-linux.jpg)
随着原来越多的计算机连接上网络计算机需要有一个属性来与其他计算机区别。如同在真实世界的人计算机也有自己属性叫hostname主机名称
### 什么是hostname ###
从它的操作手册来看hostname是用来显示系统的DNS名字以及为了显示和设置它的主机名或者NIS域名名字。所以hostname是依赖于DNSDomain Name System域名系统或者NISNetwork Information System网络信息系统
### 怎么显示hostname ###
hostname是为一个linux发行版的预安装命令。通过在控制台输入hostname可以显示你的机器的hostname。这里有一个有个简单的命令及其输出。
$ hostname
ubuntu
上面的命令将会告诉你,计算机的名字是**ubuntu** 。
### 如何设置hostname ###
Hostname当你在第一次安装你的Linux的时候已经设置好了。 就是在你安装你的Linux产品的那步时将会询问你去填入主机名信息。然而**你可以稍后填写它**如果你愿意。
为了设置你的hostname你可以使用下面的命令
# hostname dev-machine
$ hostname
dev-machine
你**需要使用root权限**或者同样的权限可以设置/改变你的hostname。#号提示你在使用root用户。上述命令告诉你的计算机设置你的hostname为**dev-machine**。如果你没有收到任何错误消息那么你的hostname已经改变了。再一次使用hostname命令检查看看结果。
使用hostname命令设置你的hostname**不是永久的**。当你重启你的计算机,你的设定将会取消。**为了永久改变**你必须手动地修改hostname配置文件。
**On Debian / Ubuntu based Linux**
**基于Linux 的 Debian / Ubuntu**
你可以在下列文件夹找到这个文件,
**/etc/hostname**
或者
**/etc/hosts**
下面是每一个文件的内容
**/etc/hostname**
# vi /etc/hostname
dev-machine
**/etc/hosts**
# vi /etc/hosts
127.0.0.1 localhost
127.0.0.1 dev-machine
你将会发现修改它会立即生效而不用重启你的linux。
**On RedHat / CentOS based Linux**
**基于Linux的 RedHat / CentOS**
你可以在下列文件夹找到这个文件,
**/etc/hosts**
或者
**/etc/sysconfig/networks**
下面是每一个文件的内容
**/etc/hosts**
127.0.0.1 localhost.localdomain localhost dev-machine
::localhost 127.0.0.1
/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=dev-machine
### 怎么显示DNS域名 ###
来自上面的hostname的定义hostname也可以显示你的Linux的DNS名字。如果你的hostname命令会显示你的hostname那么dnsdomainname命令也就会显示你的域名。来看看这个简单的例子。
$ dnsdomainname
bris.co.id
在本篇文章dnsdomainname命令的结果是 **bris.co.id**
如果你看见结果是 (**none**),那么你的机器**没有配置完整合格的域名FQDNFully Qualified Domain Name**。Dnsdomainname命令摘取来自**/etc/hosts**文件的信息。你应该配置它为完整合格的域名格式。接下来一个简单的例子:
**/etc/hosts**
127.0.0.1 localhost.localdomain localhost dev-machine
::localhost 127.0.0.1
192.168.0.104 dev-machine.bris.co.id dev-machine
为了显示更多的细节,你可以使用参数**-v**
$ dnsdomainname -v
gethostname()=dev-machine.bris.co.id
Resolving dev-machine.bris.co.id
Result: h_name=dev-machine.bris.co.id
Result: h_aliases=dev-machine
Result: h_addr_list=192.168.0.104
### 如何显示hostname更多细节信息###
Hostname命令可以使用多个参数和一些别名如dnsdomainname命令。这里有一些参数是每日操作中有用的。下面这些命令的结果是基于**/etc/hosts**的上述配置。
**显示IP地址**
$ hostname -i
192.168.0.104
**显示域名**
$ hostname -d
bris.co.id
**显示短主机名**
$ hostname -s
dev-machine
* 这个命令将会产生与输入hostname同样的结果 *
**显示FQDN格式**
$ hostname -f
dev-machine.bris.co.id
**显示细节信息**
所有的参数包括上述信息,都可以通过使用参数**-v 和 -d** 来概括。让我们来看一个例子。
$ hostname -v -d
gethostname()=dev-machine.bris.co.id
Resolving dev-machine.bris.co.id
Result: h_name=dev-machine.bris.co.id
Result: h_aliases=dev-machine
Result: h_addr_list=192.168.0.104
bris.co.id
感到熟悉?是的,这个结果与**dnsdomainname -v**命令是相同的,同样包含上面的内容。
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/display-set-hostname-linux/
译者:[Vic___](http://blog.csdn.net/Vic___) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出