shell 命令获取主机信息

2017-10-10  本文已影响0人  Josaber

主机版本信息

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty
$ lsb_release -a |grep "Des"|sed 's@^.*on:@@g'
No LSB modules are available.
    Ubuntu 14.04.5 LTS
$ uname
Linux
$ uname -a
Linux vagrant-ubuntu-trusty-64 3.13.0-132-generic #181-Ubuntu SMP Wed Sep 13 13:25:03 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

网络信息

$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:37:62:46
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe37:6246/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1536 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1149 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:136779 (136.7 KB)  TX bytes:129519 (129.5 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:88:cd:1e
          inet addr:192.168.33.20  Bcast:192.168.33.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe88:cd1e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:235 errors:0 dropped:0 overruns:0 frame:0
          TX packets:302 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:54928 (54.9 KB)  TX bytes:44008 (44.0 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:888 (888.0 B)  TX bytes:888 (888.0 B)

查看主机名

$ echo $HOSTNAME
vagrant-ubuntu-trusty-64
$ hostname
vagrant-ubuntu-trusty-64

查看用户名

$ whoami
vagrant
$ who am i
vagrant  pts/0        Oct 10 02:19 (10.0.2.2)

Mac测试

$ uname
Darwin
$ hostname
<username>.local
$ uname -a
Darwin <username>.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64
 x86_64
$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
... ...

PS:
测试主机:you can see, it's Ubuntu 14.04.5 LTS.

上一篇 下一篇

猜你喜欢

热点阅读