Linux 系统办理员在接办一台新的办事器的时辰,若是没有好的交代文档,我们能够取得的主机信息就要靠我们自身了。良多信息是能够直接经由过程号令从主机上获得的,上面就和年夜家分享 5 个取得 Linux 主机信息的号令。(注:我应用的是 Ubuntu 13.04)
1. 检查或改动 Linux 主机名的号令
$ hostname
mylinuxbook-Inspiron-1525
从号令成果上您能够看到我的 Ubuntu 主机名是 mylinuxbook-Inspiron-1525。您可以会注重到,主机名但凡也呈如今号令提示符下,所以良多时辰我们将主机名改短一些可以会更便利应用。
经由过程以下号令来改动它:
$ sudo hostname mylinuxbook
注重,改动主机名需求 root 权限,所以我在下面应用了 sudo 号令来提升权限。若是您实行了下面的号令,那末您能够当即翻开一个新的终端,在终端中您就能够检查到您新的主机名,同时您会看到新的称号的号令提示符。
不外经由过程这个号令点窜的主机名是一个权且功用,一旦您重启您的办事器,这个称号将不会存在。若是您需求永远的点窜主机名,那末您需求点窜 /etc/hostname 文件。
2. host 号令
这个号令可让您来检查主机的 IP 信息,
$ host 谷歌.com
谷歌.com has address 74.125.236.72
谷歌.com has address 74.125.236.78
谷歌.com has address 74.125.236.73
谷歌.com has address 74.125.236.71
谷歌.com has address 74.125.236.65
谷歌.com has address 74.125.236.69
谷歌.com has address 74.125.236.66
谷歌.com has address 74.125.236.64
谷歌.com has address 74.125.236.67
谷歌.com has address 74.125.236.68
谷歌.com has address 74.125.236.70
谷歌.com has IPv6 address 2404:6800:4007:801::1004
谷歌.com mail is handled by 10 aspmx.l.谷歌.com.
谷歌.com mail is handled by 20 alt1.aspmx.l.谷歌.com.
谷歌.com mail is handled by 30 alt2.aspmx.l.谷歌.com.
谷歌.com mail is handled by 40 alt3.aspmx.l.谷歌.com.
谷歌.com mail is handled by 50 alt4.aspmx.l.谷歌.com.
从号令的运转成果我们能够看到主机的 IP (IPV4 和 IPV6)和邮件办事器相干的信息。
若是您还想检查 DNS 记实,可运用 -a 参数
$ host -a 谷歌.com
Trying 谷歌.com
;; - HEADER - opcode: QUERY, status: NOERROR, id: 34210
;; flags: qr rd ra; QUERY: 1, ANSWER: 21, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;谷歌.com. IN ANY
;; ANSWER SECTION:
谷歌.com. 211 IN AAAA 2404:6800:4007:800::1009
谷歌.com. 299 IN MX 10 aspmx.l.谷歌.com.
谷歌.com. 299 IN MX 50 alt4.aspmx.l.谷歌.com.
谷歌.com. 299 IN MX 20 alt1.aspmx.l.谷歌.com.
谷歌.com. 299 IN MX 30 alt2.aspmx.l.谷歌.com.
谷歌.com. 299 IN MX 40 alt3.aspmx.l.谷歌.com.
谷歌.com. 267 IN A 74.125.236.168
谷歌.com. 267 IN A 74.125.236.165
谷歌.com. 267 IN A 74.125.236.166
谷歌.com. 267 IN A 74.125.236.167
谷歌.com. 267 IN A 74.125.236.164
谷歌.com. 267 IN A 74.125.236.174
谷歌.com. 267 IN A 74.125.236.163
谷歌.com. 267 IN A 74.125.236.169
谷歌.com. 267 IN A 74.125.236.162
谷歌.com. 267 IN A 74.125.236.161
谷歌.com. 267 IN A 74.125.236.160
谷歌.com. 136467 IN NS ns3.谷歌.com.
谷歌.com. 136467 IN NS ns1.谷歌.com.
谷歌.com. 136467 IN NS ns4.谷歌.com.
谷歌.com. 136467 IN NS ns2.谷歌.com.
Received 412 bytes from 127.0.1.1#53 in 30 ms
若是您需求检查域名办事器或 SOA 信息,可运用 -C 参数
$ host -C 谷歌.com
Nameserver 216.239.38.10:
谷歌.com has SOA record ns1.谷歌.com. dns-admin.谷歌.com. 2013061800 7200 1800 1209600 300
Nameserver 216.239.34.10:
谷歌.com has SOA record ns1.谷歌.com. dns-admin.谷歌.com. 2013061800 7200 1800 1209600 300
Nameserver 216.239.36.10:
谷歌.com has SOA record ns1.谷歌.com. dns-admin.谷歌.com. 2013061800 7200 1800 1209600 300
Nameserver 216.239.32.10:
谷歌.com has SOA record ns1.谷歌.com. dns-admin.谷歌.com. 2013061800 7200 1800 1209600 300
或您可运用 -d 或 -v 参数来输入详细信息
$ host -v 谷歌.com
Trying 谷歌.com
;; - HEADER - opcode: QUERY, status: NOERROR, id: 52674
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;谷歌.com. IN A
;; ANSWER SECTION:
谷歌.com. 77 IN A 74.125.236.40
谷歌.com. 77 IN A 74.125.236.38
谷歌.com. 77 IN A 74.125.236.34
谷歌.com. 77 IN A 74.125.236.37
谷歌.com. 77 IN A 74.125.236.36
谷歌.com. 77 IN A 74.125.236.41
谷歌.com. 77 IN A 74.125.236.35
谷歌.com. 77 IN A 74.125.236.33
谷歌.com. 77 IN A 74.125.236.46
谷歌.com. 77 IN A 74.125.236.32
谷歌.com. 77 IN A 74.125.236.39
Received 204 bytes from 127.0.1.1#53 in 33 ms
Trying 谷歌.com
;; - HEADER - opcode: QUERY, status: NOERROR, id: 31473
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;谷歌.com. IN AAAA
;; ANSWER SECTION:
谷歌.com. 28 IN AAAA 2404:6800:4007:800::1002
Received 56 bytes from 127.0.1.1#53 in 28 ms
Trying 谷歌.com
;; - HEADER - opcode: QUERY, status: NOERROR, id: 2871
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;谷歌.com. IN MX
;; ANSWER SECTION:
谷歌.com. 13 IN MX 40 alt3.aspmx.l.谷歌.com.
谷歌.com. 13 IN MX 50 alt4.aspmx.l.谷歌.com.
谷歌.com. 13 IN MX 10 aspmx.l.谷歌.com.
谷歌.com. 13 IN MX 20 alt1.aspmx.l.谷歌.com.
谷歌.com. 13 IN MX 30 alt2.aspmx.l.谷歌.com.
Received 136 bytes from 127.0.1.1#53 in 29 ms
这个号令可让您获得年夜量的主机信息。
3. arch 号令
这个号令可让您取得系统的处置器系统构架信息。
$ arch
x86_64
从号令实行成果来看,我的主机是 64 位的 x86 系列处置器。
4. uname 号令
下面的 arch 只能取得系统的俭朴信息,若是想取得更多的信息,我们就需求应用 uname 号令了,uname 号令能够取得到支配系统称号、内核称号、内核版本、主机名、搜集节点等信息。
应用 -o 参数来检查支配系统称号
$ uname -o
GNU/Linux
应用 -s 参数来检查内核称号
$ uname -s
Linux
应用 -m 参数来检查系统构架信息,这个参数的取得的成果和下面的 arch 是一样的
$ uname -m
x86_64
还有以下号令您能够试一试:
$ uname -n
linuxuser-laptop
$ uname -r
2.6.32-21-generic
$ uname -v
#33-Ubuntu SMP Fri Apr 18 08:09:38 UTC 2011
5. dig 号令
dig 号令是 DNS 检查东西,应用此号令能够检查域名办事器的主机地址
$ dig 谷歌.com
; DiG 9.9.2-P1 谷歌.com
;; global options: +cmd
;; Got answer:
;; - HEADER - opcode: QUERY, status: NOERROR, id: 40090
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;谷歌.com. IN A
;; ANSWER SECTION:
谷歌.com. 227 IN A 74.125.236.33
谷歌.com. 227 IN A 74.125.236.38
谷歌.com. 227 IN A 74.125.236.46
谷歌.com. 227 IN A 74.125.236.40
谷歌.com. 227 IN A 74.125.236.32
谷歌.com. 227 IN A 74.125.236.37
谷歌.com. 227 IN A 74.125.236.34
谷歌.com. 227 IN A 74.125.236.35
谷歌.com. 227 IN A 74.125.236.41
谷歌.com. 227 IN A 74.125.236.39
谷歌.com. 227 IN A 74.125.236.36
;; Query time: 30 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Sat Jun 22 15:38:58 2013
;; MSG SIZE rcvd: 215