In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how Linux queries OS, CPU, memory, and hard disk information. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
one。 Preface
When we take over one or more servers, first of all, we need to have some understanding of the basic configuration of the server, so that we can prescribe the right medicine for the future software deployment, the system operation and maintenance will get twice the result with half the effort.
two。 About basic server configuration
Query the basic configuration of the server generally query the operating system, CPU, memory, hard disk, the following one by one to explain.
2.1 query for basic configuration of the operating system
View operating system version
# cat / etc/redhat-release this command is mainly used to check the version number of the operating system issued by Red Hat [root@node5 ~] # cat / etc/redhat-release CentOS Linux release 7.4.1708 (Core) # cat / etc/issue this command applies to most linux distributions [root@node5 ~] # cat / etc/issue\ S Kernel\ r on an\ m
View the operating system kernel version
[root@node5] # uname-r 3.10.0-693.el7.x86_64
View operating system details
[root@node5 ~] # uname-a Linux node5 3.10.0-693.el7.x86_64 # 1 SMP Tue Aug 22 21:09:27 UTC 2017 x86 "64 GNU/Linux # you can see from the above output that the server hostname is node5,linux kernel version 3.10.0-693.el7.x86_64 CPU is x86 architecture # this command can view more information [root@node5 ~] # more / etc/*release: / etc/centos-release: CentOS Linux release 7.4.1708 (Core): / etc/os-release: NAME= "CentOS Linux" VERSION= "7 (Core)" ID= "centos" ID_LIKE= "rhel fedora" VERSION_ID= "7" PRETTY_NAME= "CentOS Linux 7 (Core)" ANSI_COLOR= "0 31 "CPE_NAME=" cpe:/o:centos:centos:7 "HOME_URL=" https://www.centos.org/" BUG_REPORT_URL= "https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT=" CentOS-7 "CENTOS_MANTISBT_PROJECT_VERSION=" 7 "REDHAT_SUPPORT_PRODUCT=" centos "REDHAT_SUPPORT_PRODUCT_VERSION=" 7 ": / etc/redhat-release:: CentOS Linux release 7.4.1708 (Core): / etc/system-release: CentOS Linux release 7.4.1708 (Core)
2.2 CPU basic configuration query
Noun interpretation
Noun meaning CPU physical number of cpu actually inserted on the motherboard number of CPU cores number of chipsets on a single CPU that can handle data, such as dual-core, quad-core (cpu cores) logical CPU number / thread number in general, logical cpu= physical CPU number × number of each core, if not equal, it means that the server's CPU supports hyper-threading technology
Check the physical number of CPU
[root@node5 ~] # grep 'physical id' / proc/cpuinfo | sort-u | wc-l 1
View the number of CPU cores
[root@node5 ~] # grep 'core id' / proc/cpuinfo | sort-u | wc-l 4
View number of CPU threads
# logical cpu number: in general, the number of logical cpu= physical CPU × the number of cores per core. If it is not equal, it means that the server's CPU supports hyper-threading technology (HT: to put it simply, it enables one kernel in the processor # to function as two cores in the operating system. In this way, the execution resources available to the operating system are doubled, and the overall performance of the system is greatly improved. In this case, the number of physical CPU of cpu= in logic # series x2) [root@node5 ~] # cat / proc/cpuinfo | grep "processor" | wc-l 4 [root@node5 ~] # grep 'processor' / proc/cpuinfo | sort-u | wc-l 4
View CPU model
[root@node5 ~] # cat / proc/cpuinfo | grep name | sort | uniq model name: Intel (R) Core (TM) i7-8550U CPU @ 1.80GHz [root@node5 ~] # dmidecode-s processor-version | uniq # uses uniq to remove weight Intel (R) Core (TM) i7-8550U CPU @ 1.80GHz
View the details of CPU
# CPU has several cores Several repetitive messages [root@node5 ~] # cat / proc/cpuinfo processor: 0 vendor_id: GenuineIntel cpu family: 6 model: 142 model name: Intel (R) Core (TM) i7-8550U CPU @ 1.80GHz stepping: 10 microcode: 0x96 cpu MHz: 2000.921 cache size: 8192 KB physical id: 0 siblings: 4 core id: 0 cpu cores: 4 apicid: 0 initial apicid: 0 fpu: Yes fpu_exception: yes cpuid level: 22 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 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec arat Bogomips: 4002.00 clflush size: 64 cache_alignment: 64 address sizes: 43 bits physical 48 bits virtual power management:
View the details of CPU
[root@node5 ~] # lscpu Architecture: x86 / 64 CPU op-mode (s): 32-bit 64-bit Byte Order: Little Endian CPU (s): 4 On-line CPU (s) list: 0-3 Thread (s) per core: 1 Core (s) per socket: 4 Socket (s): 1 NUMA node (s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 142 Model name: Intel (R) Core (TM) i7-8550U CPU @ 1.80GHz Stepping: 10 CPU MHz: 2000.921 BogoMIPS: 4002.00 Virtualization: VT-x Hypervisor vendor: VMware Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 819K NUMA node0 CPU (s): 0-3 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec arat
Summary of CPU configuration
From the above query, we can know that the server is a 4-core CPU, the CPU model is Intel (R) Core (TM) i7-8550U CPU @ 1.80GHz, and the CPU is not hyper-threaded.
2.3 basic memory configuration query
Noun interpretation
Noun meaning Mem memory usage overview table Swap virtual memory. That is, the data can be stored on the hard disk, when the physical memory is insufficient, take out part of the hard disk space to be used as SWAP partition (virtual memory), so as to solve the lack of memory capacity. SWAP means swapping. As the name implies, when a process requests OS for insufficient memory, OS will swap out data that is temporarily unused in memory and put it in the SWAP partition. This process is called SWAP OUT. When a process needs this data again and OS finds that there is still free physical memory, it swaps the data from the SWAP partition back into physical memory, a process called SWAP IN. Of course, there is a limit to the size of the swap, and once the swap is used up, the operating system will trigger the OOM-Killer mechanism to kill the process that consumes the most memory to free memory. Shared shared memory, that is, the value of physical memory shared with ordinary users, is mainly used for interprocess communication. Buffers is used to store data to be output to disk (block device). Cached stores data read from disk. Total physical memory of total, memory used by total=used+freeused free free memory
Query server memory
[root@node5] # free-m total used free shared buff/cache available Mem: 3941 286 3446 19 208 3407 Swap: 2047 0 2047 # Note # the idea of linux's memory management mechanism includes (dare not say that is) memory utilization maximization. The kernel requests the remaining memory as cached, while cached does not fall into the category of free. When the system runs # lines for a long time, you will find that the cached is very large, especially for systems with frequent file read and write operations. Intuitively, at this time, the memory of free will be very small, but it does not mean that the memory used by # # is small. When a program needs to apply for larger memory, if the memory of free is not enough, the kernel will reclaim part of the memory of cached and redistribute the recovered memory to the application. So # for linux systems, the memory available for allocation is not only free memory, but also cached memory (which actually includes buffers). # for operating systems: # MemFree=total-used # MemUsed = MemTotal-MemFree # for applications: # MemFree=buffers+cached+free
Query memory every 3 seconds
[root@node5] # free-s 3 total used free shared buff/cache available Mem: 4036316 361144 3458272 19536 216900 3419776 Swap: 2097148 0 2097148 total used free shared buff/cache available Mem: 4036316 361144 3458272 19536 216900 3419776 Swap: 2097148 0 2097148 total used free shared buff/cache available Mem: 4036316 361144 3458272 19536 216900 3419776 Swap: 2097148 0 2097148
2.4 query for basic configuration of hard disk
Query the overall disk usage
[root@node5 ~] # df-h Filesystem Size Used Avail Use% Mounted on / dev/mapper/centos-root 17G 4.1G 13G 24% / devtmpfs 2.0G 02.0G 0% / devtmpfs 2.0G 8.0K 2.0G 1% / dev/shm tmpfs 2.0G 8.7M 2.0G 1% / run tmpfs 2.0G 02.0G 0% / sys/fs/cgroup / dev/sda1 1014M 125M 890M 13% / boot tmpfs 395M 0395M 0% / run/user/0 # Command extension # df-a shows the usage of all file systems # df-I displays inode information # df-k bytes Display block occupancy # df-T shows the type of file system
Query the disk usage of a directory
# Command extension # du-s specified directory size summary # du-h with unit of measurement # du-a contains file # du-max-depth=1 subdirectory depth # du-c list details at the same time Increase the total value [root@node5 ~] # du-sh / home/ 1.7g / home/ [root@node5 ~] # du-ach-- max-depth=2 / home/ 4.0K / home/www/.bash_logout 4.0K / home/www/.bash_profile 4.0K / home/www/.bashrc 4.0K / home/www/web 16K / home/www 4.0K / home/nginx/.bash_logout 4.0K / home/ Nginx/.bash_profile 4.0K / home/nginx/.bashrc 12K / home/nginx 4.0K / home/esnode/.bash_logout 4.0K / home/esnode/.bash_profile 4.0K / home/esnode/.bashrc 4.0K / home/esnode/.oracle_jre_usage 4.3M / home/esnode/elasticsearch-analysis-ik-6.2.2.zip 80M / home/esnode/kibana-6.2.2-linux-x86_64.tar. Secret key generated by gz 300m / home/esnode/x-pack-6.2.2.zip 28m / home/esnode/elasticsearch-6.2.2.tar.gz 4.0K / home/esnode/.bash_history 294m / home/esnode/elasticsearch-6.2.2 4.0K / home/esnode/.ssh 4.0K / home/esnode/x-pack. Txt 1014m / home/esnode/kibana-6.2.2-linux-x86_64 8.0K / home / esnode/.viminfo 1.7G / home/esnode 1.7G / home/ 1.7G total
View directory structure
# tree command is not installed by default You need to manually install [root@node5 ~] # yum-y install tree #-L specify directory depth [root@node5 ~] # tree-L 2 / home/ / home/ ├── esnode │ ├── elasticsearch-6.2.2 │ elasticsearch-6.2.2.tar.gz │ ├── elasticsearch-analysis-ik-6.2.2.zip │ ├── kibana-6.2. 2-linux-x86_64 │ ├── kibana-6.2.2-linux-x86_64.tar.gz │ ├── x-pack-6.2.2.zip │ └── x-pack\ 347\ 224\ 237\ 346\ 210\ 220\ 347\ 232\ 204\ 347\ 247\ 230\ 351\ 245.txt ├── nginx └── www web 6 directories 5 files
Displays all available block device information in a tree format
[root@node5 ~] # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─ sda1 8:1 0 1G 0 part / boot └─ sda2 8:2 0 19G 0 part ├─ centos-root 253 sda2 0 017G 0 lvm / └─ centos-swap 253 Switzerland 1 02G 0 lvm [SWAP] sdb 8:16 0 1G 0 disk └─ sdb1 8:17 0200M 0 part sr0 11:0 1 1024M 0 rom # Note # NAME-- name of the device # MAJ:MIN-- each device in the Linux operating system is represented by a file For block (disk) devices, the primary and secondary device numbers are used to describe the device. # RM-removable device. If this is a removable device, 1 will be displayed, otherwise 0 will be displayed. # TYPE-- Type of device # MOUNTPOINT-- location where the device is mounted # RO-- for read-only file systems, 1 is displayed, otherwise 0 is displayed. # SIZE-the capacity of the device
List all available devices, universal unique identification number (UUID), file system type, and volume label
[root@node5 ~] # blkid / dev/sda1: UUID= "6503b4ad-2975-4152-a824-feb7bea1b622" TYPE= "xfs" / dev/sda2: UUID= "nqZ4uJ-ksnN-KzYS-N42b-00m3-Ohc2-BJXunP" TYPE= "LVM2_member" / dev/sdb1: UUID= "94396e17-4821-4957-aa76-d41f33958ff5" TYPE= "xfs" / dev/mapper/centos-root: UUID= "c1d38b37-821d-48e7-8727-3937ccc657a4" TYPE= "xfs" / dev/mapper/centos-swap: UUID= "c2fcaf11-42d8-4e4c-bf9e-6464f0777198" TYPE= "swap" Thank you for reading! On "Linux how to query OS, CPU, memory, hard disk information" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.