查看Linux系统信息

1、查看内核

$ uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


$  uname -r
3.10.0-514.el7.x86_64


$  cat /proc/version 
Linux version 3.10.0-514.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016

2、查看发行版信息(是centos还是ubuntu)

$ cat /etc/issue

CentOS release 6.7 (Final)
Kernel \r on an \m


$ cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core)


$ cat /etc/os-release |grep VERSION
VERSION="7 (Core)"
VERSION_ID="7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT_VERSION="7"


$  lsb_release -a       # 前提是安装这个命令,yum install redhat-lsb,安装包很多,将近80M
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.3.1611 (Core) 
Release: 7.3.1611
Codename: Core

3、查看cpu内存信息

$ cat /proc/cpuinfo 

$ cat /proc/meminfo

4、查看是64位还是32位

$ getconf LONG_BIT
64

$ file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=3d705971a4c4544545cb78fd890d27bf792af6d4, stripped

5、查看是物理机还是虚拟机

$ dmidecode | grep Product
	Product Name: KVM


$ dmidecode -s system-product-name
KVM


$ dmesg | grep -i virtual     #这个貌似靠谱

[    0.000000] Booting paravirtualized kernel on KVM
[    0.371892] KVM setup paravirtual spinlock
[    1.073490] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input2
[    1.073682] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input3
[    1.131477] systemd[1]: Detected virtualization kvm.
[    1.205052] systemd[1]: Starting Setup Virtual Console...

6、查看和更改系统当前的运行级别

 runlevel 命令用来显示之前的运行级别和现在的运行级别。如果第一个输出参数是 'N',那么在启动系统之后,运行级别就不会发生改变。

 

查看运行级别

[root@pinguino ~]# runlevel

N 3

 

更改运行级别

[root@pinguino ~]# telinit 5

 

确认新的运行级别

[root@pinguino ~]# runlevel

3 5

7、查看机器的公网ip

curl icanhazip.com
curl ipinfo.io/ip
curl www.trackip.net/i
curl ipinfo.io/json
curl www.trackip.net/ip?json
wget http://ipecho.net/plain -O - -q ; echo
host -t a dartsclink.com | sed 's/.*has address //'
dig +short myip.opendns.com @resolver1.opendns.com
wget http://ipecho.net/plain -O - -q ; echo
wget http://observebox.com/ip -O - -q ; echo
curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+"

你可能感兴趣的:(linux)