Linux View System Information Method Summary __linux

Source: Internet
Author: User
Tags data structures echo command readable disk usage
How to view system startup time and run time under Linux
1. View/proc/uptime file Computing system startup time:
Cat/proc/uptime
Output: 5113396.94 575949.85

The first number is the system has been running for 5,113,396,.94 seconds, using the System Tools date to calculate the system start time


Date-d "$ (awk-f. ' {print} '/proc/uptime) second ago" + "%y-%m-%d%h:%m:%s"
Output: 2018-01-02 06:50:52


2. View/proc/uptime files calculate system run time
cat/proc/uptime| Awk-f. ' {run_days=$1/86400;run_hour= (% 86400)/3600;run_minute= (% 3600)/60;run_second=$1% 60;printf ("system is running:%d days% D%d minutes%d seconds ", Run_days,run_hour,run_minute,run_second)} '
Output: System is running: 1 days 1:36 13 seconds


Linux view the number of physical CPUs, the number of cores, the number of logical CPUs
# Total Kernel = number of physical CPUs X number of cores per physical CPU
# Total Logical CPUs = number of physical CPUs x number of cores per physical CPU x Hyper-Threading


# View the number of physical CPUs
cat/proc/cpuinfo| grep "Physical ID" | Sort| uniq| Wc-l
2


# View the number of cores in each physical CPU (that is, the kernel number)
cat/proc/cpuinfo| grep "CPU Cores" | Uniq
CPU Cores:2


# View the number of logical CPUs
cat/proc/cpuinfo| grep "Processor" | Wc-l
4


# View CPU information (model)
Cat/proc/cpuinfo | grep name | Cut-f2-d: | Uniq-c
4 Intel (R) Core (TM) i5-6500 CPU @ 3.20GHz


Enter the command Cat/proc/cpuinfo view a few physical IDs have several physical CPUs; see processor several have several logical CPUs.
(i) Conceptual
① Physical CPU
Number of CPUs on slots in actual server
Number of physical CPUs, several physical IDs can be counted
② Logical CPU
/proc/cpuinfo used to store CPU hardware information.
The information content lists the specification of processor 0–processor N respectively. Note here that n+1 is the logical number of CPUs
In general, we think that a CPU can have multi-core, plus Intel's Hyper-Threading Technology (HT), which can logically be divided into a second number of CPU core out
Logical CPUs = number of physical CPUs x CPU cores This metric value x 2 (if HT is supported and turned on)
Note: Linux top view CPU is also the number of logical CPUs
③CPU Nuclear number
The number of chipsets that can process data on a single CPU, such as the current i5 760, is a dual-core four-thread CPU, and i5 2250 is a quad-core four-threaded CPU
In general, the number of physical CPUs x per kernel should equal the number of logical CPUs, if not equal, the server's CPU support Hyper-Threading Technology


Practical commands for viewing system information
LSCPU command to view CPU statistics

blue@blue-pc:~$ lscpu
Architecture:          i686            #cpu架构
CPU Op-mode (s):        32-bit, 64-bit
Byte Order:            Little endian   #小端字节序
CPU (s):                4               #总共有4核
on-line CPU (s) List:   0-3
Thread (s) per Core:    1               #每个cpu核, only one thread is supported, that is, Hyper-threading
core (s) per socket:    4               #每个cpu with 4 core
sockets (s):             1               #总共有1一个cpu
vendor ID:             Genuineintel    #cpu产商 Intel
CPU Family:            6
Model:                 a
Stepping:              7
CPU MHz:               1600.000
bogomips:              5986.12
Virtualization:        vt-x            # Support CPU Virtualization Technology
L1D cache:             32K
l1i cache:             32K
L2 cache:              256K
L3 cache:              6144K
See/proc/cpuinfo, you can know each CPU information, such as the model of each CPU, frequency and so on.


Memory
Overview view of Memory

Free-m
             Total       used       free     shared    buffers     cached
Mem:          3926          3651 274 0        404
-/+ buffers/cache:       3235        691
Swap:         9536       9505
The unit here is MB and the total memory is 3926MB.
View Memory Detail Usage: cat/proc/meminfo

Disk

View hard disk and partition distribution

# lsblk
NAME   maj:min RM   SIZE RO TYPE mountpoint
SDA      8:0    0 465.8G  0 disk 
├─SDA1   8:1    0     1G  0 part/boot
├─sda2   8:2    0   9.3G  0 part [SWAP]
├─sda3   8:3    0  74.5G  0/
├─sda4   8:4    0     1K 0 part 
├─sda5   8:5    0 111.8G  0 part/home
└─sda6   8:6    0 269.2G  0 part
If you want to see the details of your hard disk and partitions

# fdisk-l

disk/dev/sda:500.1 GB, 500107862016 bytes heads, MB sectors/track,
60801 cylinders, total 976773168 s Ectors
Units = sectors of 1 * The bytes
sector size (logical/physical): bytes/4096 bytes
I/o size (minimum/optimal): 4096 bytes/4096 bytes
Disk identifier:0x00023728

   Boot      Start      End Blocks   Id  System
/dev/sda1   *        2048     2148351     1073152  Linux
/ Dev/sda2         2148352    21680127     9765888  Linux swap/solaris
/dev/sda3        21680128   177930239    78125056
/dev/sda4       177932286   976771071   399419393    5  Extended/dev/sda5       177932288   412305407   117186560  Linux
/dev/sda6       412307456   976771071   282231808  Linux
Use the "df-k" command to display disk usage and occupancy in kilobytes, and-m to display disk usage and occupancy rates in m units

root@debian:~# df-k
filesystem     1k-blocks    Used Available use% mounted on
/dev/sda1        8518920 1484432   6578708  19%/
udev               10240       0     10240   0%/dev
tmpfs              98488   12908     85580  14%/run
tmpfs             246216       0    246216   0%/dev/shm
tmpfs               5120       0      5120   0%/run/lock
tmpfs             246216       0    246216
0%/sys/fs/cgroup/dev/sda7         368615    2055    343008   1%/tmp
/dev/sda8       28202140  9678620 17067856 37%/home
/dev/sda5        2817056  803380   1850860  31%/var
Use the "du-k/home" command to list the size of all files or directories under the home directory, in kilobytes as units of measure.
The following command can view the size of the/home directory:
root@debian:~# Du-sh/home
9.2g/home


Card
View network card hardware information
# Lspci | Grep-i ' ETH '
02:00.0 Ethernet Controller:realtek Semiconductor Co., Ltd. rtl8111/8168b PCI Express Gigabit Ethernet Controller (Rev. 06 )

View all network interfaces for the system

# ifconfig-a
eth0      Link encap: Ethernet  Hardware address b8:97:5a:17:b3:8f

... Lo        Link encap: Local loopback  
          ...
or
IP link show
1:lo: <LOOPBACK> MTU 16436 qdisc noqueue State down 
link/loopback 00:00:00:00:00:00 b Rd 00:00:00:00:00:00
2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU 1500 Qdisc pfifo_fast State up Qlen 1000
  link/ether b8:97:5a:17:b3:8f BRD FF:FF:FF:FF:FF:FF
If you want to view the details of a network interface, such as the detailed parameters and metrics for eth0
# ethtool eth0
Settings for eth0:
    supported ports: [TP MII]
    supported link modes:   10baset/half 10baset/f ull 
                            100baset/half 100baset/full 
                            1000baset/half 1000baset/full #支持千兆半双工, full duplex mode
    supported pause frame use: No 
    Supports Auto-negotiation:yes #支持自适应模式, generally support
    advertised link modes:  10baset/half 10baset/full 
                            100baset/half 100baset/full 
                            1000baset/half 1000baset/full
    advertised pause frame use:symmetric Receive-only
    advertised Auto-negotiation:yes #默认使用自适应模式
    link partner advertised link modes:  10baset/ Half 10baset/full 
                                         100baset/half 100baset/full ...
    SPEED:100MB/S #现在网卡的速度是100Mb, the network card using adaptive mode, so speculated that the route is 100Mb, resulting in the network card from the support of gigabit, to support the hundred trillion
    duplex:full   #全双工 ...
    Link detected:yes    #表示有网线连接, and routing is through
Other
View PCI information, which is all hardware slot information for the motherboard.

Lspci 00:00.0 Host Bridge:intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev.) #主板芯片 00:02.0 V GA compatible Controller:intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev. 09) #  Graphics card 00:14.0 USB controller:intel Corporation Panther point USB xhci Host Controller (rev.) #usb控制器 00:16.0 Communication Controller:intel Corporation Panther Point MEI Controller #1 (rev.) 00:1a.0 USB Controller:intel Corporation Panther  Point USB Enhanced Host Controller #2 (rev.) 00:1b.0 Audio Device:intel Corporation Panther Point High Definition Audio Controller (REV) #声卡 00:1c.0 PCI Bridge:intel Corporation Panther Point PCI Express Root Port 1 (Rev C4) #pci slot 00:1 C.2 PCI Bridge:intel Corporation Panther Point PCI Express Root Port 3 (Rev C4) 00:1c.3 PCI Bridge:intel Corporation Pan Ther point PCI Express Root Port 4 (rev. C4) 00:1d.0 usb controller:intel Corporation Panther Point usb enhanced Host Cont Roller #1 (rev.) 00:1f.0 ISA Bridge:intel Corporation Panther point LPC Controller (rev.) 00:1f.2 IDE Interface:intel Corporation Panther Po int 4 port SATA Controller [IDE mode] (rev) #硬盘接口 00:1f.3 Smbus:intel Corporation Panther point SMBus Controller (rev. 00:1F.5 IDE Interface:intel Corporation Panther point 2 port SATA Controller [IDE mode] (rev) #硬盘接口 02:00.0 Ethern ET Controller:realtek Semiconductor Co., Ltd. rtl8111/8168b PCI Express Gigabit Ethernet Controller (Rev. #网卡 03:00.0 PCI bridge:integrated Technology Express, Inc. Device 8893 (Rev. 41)
If you want more detailed information: Lspci-v or LSPCI-VV
If you want to see the device tree: lspci-t

View BIOS Information

# dmidecode-t BIOS ...
BIOS Information
    Vendor:american Megatrends Inc.
    version:4.6.5 release
    date:04/25/2012
    ..... BIOS revision:4.6 ...
Dmidecode the DMI (Desktop Management Interface) information of the machine in a readable manner. This information includes hardware and BIOS, both for the current configuration and for the maximum configuration supported by the system, such as the maximum number of memory supported.
If you want to see all the useful information
Dmidecode-q
It contains a lot of hardware information.
Note: The above commands are Ubuntu. Ubuntu supports a number of commands, relatively redhat will be complete. After all, Redhat requires stability, so the update will be slow. (Some commands redhat and CentOS may not, I test Debian can also)


Linux/proc Directory Detailed
1./proc Directory
The Linux kernel provides a mechanism for accessing kernel internal data structures and changing kernel settings through the/proc file system at run time. Proc File system is a pseudo file system, it only exists in memory, and does not occupy the storage space. It provides an interface to the operation of accessing system kernel data in a file system manner.
Users and applications can get information about the system through proc and can change some of the kernel's parameters. Because the information of the system, such as the process, is dynamically changed, so the user or application reads the proc file, the proc file system is dynamically reading the required information from the system kernel and submitting it. The files or subfolders listed below are not all present in your system, depending on your kernel configuration and loaded modules. In addition, there are three important directories under/proc: NET,SCSI and Sys. The SYS directory is writable and can be used to access or modify kernel parameters, while net and SCSI depend on the kernel configuration. For example, if the system does not support SCSI, the SCSI directory does not exist.
In addition to the above, there are some numbers-named directories, which are the process catalogs. Each process currently running in the system has a corresponding directory under/proc, with the process's PID number as the directory name, which is the interface for reading process information. The self directory is the information interface that reads the process itself, and is a link.


2. Child files or subfolders
/proc/buddyinfo How many pieces of each order in each memory area are available, and memory fragmentation issues
/proc/cmdline parameter information passed to kernel at startup
/proc/cpuinfo information about the CPU
All installed encrypted passwords and details used by the/proc/crypto kernel
/proc/devices devices that have been loaded and sorted
/PROC/DMA the list of ISA DMA channels that are registered for use
/proc/execdomains Linux kernel currently supported execution domains
/PROC/FB Frame buffer device list, including quantity and control of its driver
File system types currently supported by the/proc/filesystems kernel
/proc/interrupts the number of per IRQ interrupts in the x86 schema
/proc/iomem the current mapping of each physical device in system memory
/proc/ioports the registered port range used by the input and output of a device
/proc/kcore represents the physical memory of the system, stored as the core file format, which shows the number of bytes, equal to ram size plus 4KB
/proc/kmsg records kernel-generated information that can be handled by/SBIN/KLOGD or/BIN/DMESG
/proc/loadavg the state of the load based on CPU and IO over a period of time, related to the uptime command
/proc/locks kernel-locked file list
/proc/mdstat multiple hard drives, RAID configuration information (Md=multiple disks)
Information about the use of/proc/meminfo RAM
/proc/misc driver registered on other major equipment (unit Number 10)
/proc/modules the list of all modules loaded into the kernel
All mounts used in the/proc/mounts system
Memory Type Range Registers (MTRRS) used by the/PROC/MTRR system
Block allocation information in a/proc/partitions partition
List of PCI devices in the/PROC/PCI system
/proc/slabinfo Slab cache information for all activities in the system
/proc/stat All CPU activity information
When/proc/sysrq-trigger uses the echo command to write this file, the remote root user can perform most of the system request-critical commands as if they were performed at the local terminal. To write to this file, you need to set the/PROC/SYS/KERNEL/SYSRQ to 0. This file is not readable for root
How long has the/proc/uptime system been running?
Use of/proc/swaps swap space
/proc/version Linux kernel version and GCC version
/proc/bus system bus (buses) information, such as PCI/USB, etc.
/proc/driver Driver Information
/PROC/FS File System Information
/proc/ide IDE Device Information
/PROC/IRQ Interrupt Request Device information
/proc/net Network card Device information
/PROC/SCSI SCSI Device Information
/proc/tty TTY Device Information
/proc/net/dev Display network adapters and statistics
/proc/vmstat Virtual Memory Statistics
Memory image when/proc/vmcore kernel panic
/proc/diskstats Get disk information
/proc/schedstat Kernel Scheduler Statistics
/proc/zoneinfo Displays the memory space statistics and is useful for analyzing virtual memory behavior

The following is information about process n in the/proc directory
Process information for/proc/n PID N
/proc/n/cmdline Process Start command
/PROC/N/CWD link to the current working directory of the process
/proc/n/environ Process Environment Variables list
/proc/n/exe the execution command file linked to the process
/PROC/N/FD contains all the file descriptors associated with the process
/proc/n/maps memory-mapped information related to processes
/proc/n/mem refers to the memory held by the process and cannot be read
/proc/n/root link to the root directory of the process
/proc/n/stat the status of a process
The state of the memory used by the/PROC/N/STATM process
/proc/n/status process state information, more readable than STAT/STATM
/proc/self Link to a currently running process


Reference:
https://www.cnblogs.com/xd502djj/archive/2011/05/03/2035599.html
https://www.cnblogs.com/emanlee/ p/3587571.html
http://blog.csdn.net/chw1989/article/details/9150767
https://www.cnblogs.com/ggjucheng/ archive/2013/01/14/2859613.html
https://jingyan.baidu.com/article/e2284b2b5dd3ebe2e6118dc8.html
http:// blog.csdn.net/zdwzzu2006/article/details/7747977

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.