Linux下查看系统信息:CPU架构、位数、系统版本、内存信息等信息

 linux  Linux下查看系统信息:CPU架构、位数、系统版本、内存信息等信息已关闭评论
11月 192019
 

linux机器,网上下载软件时经常会看到软件包分成了32位/64位/x86/arm等不同的包,那自己的服务器适用哪个包?服务器具体的架构/位数可以通过什么命令查询呢?

 

#linux 操作系统的位数查看:

[[email protected] ~]$ getconf LONG_BIT
64

#查看cpu信息

[[email protected] ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
stepping : 1
microcode : 0xb000038
cpu MHz : 2300.141
cache size : 46080 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips : 4600.18
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
stepping : 1
microcode : 0xb000038
cpu MHz : 2300.141
cache size : 46080 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips : 4600.18
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual

# 总核数 = 物理CPU个数 X 每颗物理CPU的核数
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数
# 查看物理CPU个数
cat /proc/cpuinfo| grep “physical id”| sort| uniq| wc -l
# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep “cpu cores”| uniq
# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep “processor”| wc -l

 

#查看cpu硬件架构

在Linux中使用命令arch可以查看机器CPU类型,如”i386”, “i486″,”i586”, “alpha”, “sparc”, “arm”, “m68k”,”mips”, “ppc”,”ia64″,”x86_64″等;ia64和x86_64就说明这台机器是64位的;

[[email protected] ~]$ arch
x86_64

或者

[[email protected] ~]$ uname -m
x86_64

uname命令可以输出一组系统信息

[[email protected] ~]$ uname -a
Linux ip-xxx.ap-southeast-1.compute.internal 4.14.146-120.181.amzn2.x86_64 #1 SMP Fri Oct 18 17:01:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

 

#如何查看Linux操作系统版本?不同linux版本命令稍有不同,选择可以用的
[[email protected] ~] cat /proc/version
[[email protected] ~] uname -r
[[email protected] ~] lsb_release -a
[[email protected] ~] cat /etc/issue
[[email protected] ~] cat /etc/*release*
[[email protected] ~] less /etc/redhat-release

#linux查看内存信息
[[email protected] ~] cat /proc/meminfo

CentOS系统中常用查看系统信息和日志命令

 centos  CentOS系统中常用查看系统信息和日志命令已关闭评论
9月 042019
 

一、系统日志文件(可以通过cat或tail命令来查看)

/var/log/message # 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一

/var/log/secure # 与安全相关的日志信息

/var/log/maillog # 与邮件相关的日志信息

/var/log/cron # 与定时任务相关的日志信息

/var/log/spooler # 与UUCP和news设备相关的日志信息

/var/log/boot.log # 守护进程启动和停止相关的日志消息

二、系统信息

uname -a # 查看内核/操作系统/CPU信息

cat /etc/issue

cat /etc/redhat-release # 查看操作系统版本

cat /proc/cpuinfo  # 查看CPU信息

hostname # 查看计算机名

lspci -tv # 列出所有PCI设备

lsusb -tv # 列出所有USB设备

lsmod # 列出加载的内核模块

env # 查看环境变量

三、资源

free -m # 查看内存使用量和交换区使用量

df -h # 查看各分区使用情况

du -sh <目录名> # 查看指定目录的大小

grep MemTotal /proc/meminfo # 查看内存总量

grep MemFree /proc/meminfo # 查看空闲内存量

uptime # 查看系统运行时间、用户数、负载

cat /proc/loadavg # 查看系统负载

 

四、磁盘和分区

mount | column -t # 查看挂接的分区状态

fdisk -l # 查看所有分区

swapon -s # 查看所有交换分区

hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)

dmesg | grep IDE # 查看启动时IDE设备检测状况

五、网络

ifconfig # 查看所有网络接口的属性

iptables -L # 查看防火墙设置

route -n # 查看路由表

netstat -lntp # 查看所有监听端口

netstat -antp # 查看所有已经建立的连接

netstat -s # 查看网络统计信息

六、进程

ps -ef # 查看所有进程

top # 实时显示进程状态(另一篇文章里面有详细的介绍)

七、用户 

w # 查看活动用户

id <用户名> # 查看指定用户信息

last # 查看用户登录日志

cut -d: -f1 /etc/passwd # 查看系统所有用户

cut -d: -f1 /etc/group # 查看系统所有组

crontab -l # 查看当前用户的计划任务

八、服务

chkconfig –list # 列出所有系统服务

chkconfig –list | grep on # 列出所有启动的系统服务

九、程序

rpm -qa # 查看所有安装的软件包

 

来自:https://blog.csdn.net/twc829/article/details/75284332

使用MYSQL命令查看MYSQL中数据库或表占用空间的大小

 mysql  使用MYSQL命令查看MYSQL中数据库或表占用空间的大小已关闭评论
3月 062019
 

知道每个数据库的大小,使用下面步骤:

1、进入information_schema 数据库

use information_schema;

 

2、根据表名汇总查询各表数据的大小:

select TABLE_SCHEMA as tablename, concat(round(sum(data_length/1024/1024/1024),3),’GB’) as data from tables group by TABLE_SCHEMA;

 

2、查看指定数据库的大小:

比如查看数据库mydb的大小

select concat(round(sum(data_length/1024/1024/1024),3),’GB’) as data from tables where table_schema=’mydb’;

 

4、查看指定数据库的某个表的大小

比如查看数据库mydb中 mytable 表的大小

select concat(round(sum(data_length/1024/1024),3),’MB’) as data from tables where table_schema=’mydb’ and table_name=’mytable’;

curl 查看某web页页面响应时间

 linux  curl 查看某web页页面响应时间已关闭评论
5月 232017
 

近日公司访问微信统一下单接口时间变长了, 通过下面的命令:

[[email protected] ~]$   time curl -i -v -s \-o /dev/null \-w “\n\nhttp_code: %{http_code}s\nhttp_connect: %{http_connect}s\ncontent_type: %{content_type}s\ntime_namelookup: %{time_namelookup}s\ntime_redirect: %{time_redirect}s\ntime_pretransfer: %{time_pretransfer}s\ntime_connect: %{time_connect}s\ntime_starttransfer: %{time_starttransfer}s\ntime_total: %{time_total}s\nspeed_download: %{speed_download}KB/s\n” \https://api.mch.weixin.qq.com/pay/unifiedorder

返回结果:

* About to connect() to api.mch.weixin.qq.com port 443 (#0)
*   Trying 140.207.69.102… connected
* Connected to api.mch.weixin.qq.com (140.207.69.102) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS: client certificate not found (nickname not specified)
* SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
*       subject: CN=payapp.weixin.qq.com,OU=R&D,O=Tencent Technology (Shenzhen) Company Limited,L=shenzhen,ST=guangdong,C=CN
*       start date: Mar 22 00:00:00 2017 GMT
*       expire date: Jun 21 23:59:59 2018 GMT
*       common name: payapp.weixin.qq.com
*       issuer: CN=GeoTrust SSL CA – G3,O=GeoTrust Inc.,C=US
> GET /pay/unifiedorder HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: api.mch.weixin.qq.com
> Accept: */*

< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 23 May 2017 06:13:59 GMT
< Content-Type: text/plain
< Content-Length: 112
< Connection: keep-alive
< Keep-Alive: timeout=8

{ [data not shown]
* Connection #0 to host api.mch.weixin.qq.com left intact

http_code: 200s
http_connect: 000s
content_type: text/plains
time_namelookup: 15.015s
time_redirect: 0.000s
time_pretransfer: 15.180s
time_connect: 15.020s
time_starttransfer: 15.188s
time_total: 15.188s
speed_download: 7.000KB/s
* Closing connection #0

real    0m15.207s
user    0m0.076s
sys     0m0.091s

可以发现 time_namelookup: 15.015s  , 说明dns解析就花了15秒,问题找到。


******************************************************************************************************************

附:

关于curl  -w 参数下显示格式的参数有哪些(比如time_namelookup, time_pretransfer等),可参考这里:https://curl.haxx.se/docs/manpage.html


content_type The Content-Type of the requested document, if there was any.

filename_effective The ultimate filename that curl writes out to. This is only meaningful if curl is told to write to a file with the -O, –remote-name or -o, –output option. It’s most useful in combination with the -J, –remote-header-name option. (Added in 7.26.0)

ftp_entry_path The initial path curl ended up in when logging on to the remote FTP server. (Added in 7.15.4)

http_code The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.

http_connect The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)

http_version The http version that was effectively used. (Added in 7.50.0)

local_ip The IP address of the local end of the most recently done connection – can be either IPv4 or IPv6 (Added in 7.29.0)

local_port The local port number of the most recently done connection (Added in 7.29.0)

num_connects Number of new connects made in the recent transfer. (Added in 7.12.3)

num_redirects Number of redirects that were followed in the request. (Added in 7.12.3)

proxy_ssl_verify_result The result of the HTTPS proxy’s SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.52.0)

redirect_url When an HTTP request was made without -L to follow redirects, this variable will show the actual URL a redirect would take you to. (Added in 7.18.2)

remote_ip The remote IP address of the most recently done connection – can be either IPv4 or IPv6 (Added in 7.29.0)

remote_port The remote port number of the most recently done connection (Added in 7.29.0)

scheme The URL scheme (sometimes called protocol) that was effectively used (Added in 7.52.0)

size_download The total amount of bytes that were downloaded.

size_header The total amount of bytes of the downloaded headers.

size_request The total amount of bytes that were sent in the HTTP request.

size_upload The total amount of bytes that were uploaded.

speed_download The average download speed that curl measured for the complete download. Bytes per second.

speed_upload The average upload speed that curl measured for the complete upload. Bytes per second.

ssl_verify_result The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0)

time_appconnect The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)

time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.

time_namelookup The time, in seconds, it took from the start until the name resolving was completed.

time_pretransfer The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.

time_redirect The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)

time_starttransfer The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.

time_total The total time, in seconds, that the full operation lasted.

url_effective The URL that was fetched last. This is most meaningful if you’ve told curl to follow location: headers.


查看Linux操作系统信息的相关命令

 linux  查看Linux操作系统信息的相关命令已关闭评论
12月 152016
 

记录下

# uname -a # 查看内核/操作系统/CPU信息 
# head  /etc/issue # 查看操作系统版本 
# cat /proc/cpuinfo # 查看CPU信息 
# hostname # 查看计算机名 
# lspci -tv # 列出所有PCI设备 
# lsusb -tv # 列出所有USB设备 
# lsmod # 列出加载的内核模块 
# env # 查看环境变量资源 
# free -m # 查看内存使用量和交换区使用量 
# df -h # 查看各分区使用情况 
# du -sh <目录名> # 查看指定目录的大小 
# grep MemTotal /proc/meminfo # 查看内存总量 
# grep MemFree /proc/meminfo # 查看空闲内存量 
# uptime # 查看系统运行时间、用户数、负载 
# cat /proc/loadavg # 查看系统负载磁盘和分区 
# mount | column -t # 查看挂接的分区状态 
# fdisk -l # 查看所有分区 
# swapon -s # 查看所有交换分区 
# hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备) 
# dmesg | grep IDE # 查看启动时IDE设备检测状况网络 
# ifconfig # 查看所有网络接口的属性 
# iptables -L # 查看防火墙设置 
# route -n # 查看路由表 
# netstat -lntp # 查看所有监听端口 
# netstat -antp # 查看所有已经建立的连接 
# netstat -s # 查看网络统计信息进程 
# ps -ef # 查看所有进程 
# top # 实时显示进程状态用户 
# w # 查看活动用户 
# id <用户名> # 查看指定用户信息 
# last # 查看用户登录日志 
# cut -d: -f1 /etc/passwd # 查看系统所有用户 
# cut -d: -f1 /etc/group # 查看系统所有组 
# crontab -l # 查看当前用户的计划任务服务 
# chkconfig –list # 列出所有系统服务 
# chkconfig –list | grep on # 列出所有启动的系统服务程序 
# rpm -qa # 查看所有安装的软件包

9月 142015
 

Linux下查看系统版本号信息的方法,记录下

一、查看Linux内核版本命令(两种方法):

1、cat /proc/version

[[email protected] ~]# cat /proc/version
Linux version 2.6.18-194.8.1.el5.centos.plus ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Wed Jul 7 11:50:45 EDT 2010

2、uname -a

[[email protected] ~]# uname -a
Linux localhost.localdomain 2.6.18-194.8.1.el5.centos.plus #1 SMP Wed Jul 7 11:50:45 EDT 2010 i686 i686 i386 GNU/Linux

二、查看Linux系统版本的命令(3种方法):

1、lsb_release -a,即可列出所有版本信息:

[[email protected] ~]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.5 (Final)
Release: 5.5
Codename: Final

这个命令适用于所有的Linux发行版,包括Redhat、SuSE、Debian…等发行版。

2、cat /etc/redhat-release,这种方法只适合Redhat系的Linux:

[[email protected] ~]# cat /etc/redhat-release
CentOS release 5.5 (Final)

3、cat /etc/issue,此命令也适用于所有的Linux发行版。

[[email protected] ~]# cat /etc/issue
CentOS release 5.5 (Final)
Kernel r on an m

转自http://www.ha97.com/2987.html