• Linux学习笔记


    Linux学习笔记 - 系统、CPU、内存、进程

    一、查看系统版本命令

    1、uname -参数 :查看内核版本

    # uname -参数
    uname -a
    uname -r #查看内核版本
    uname -m
    uname -n

    效果

    [root@ecs-aece ~]# uname
    Linux
    [root@ecs-aece ~]# uname -m
    x86_64
    [root@ecs-aece ~]# uname -n
    ecs-aece
    [root@ecs-aece ~]# uname -r
    4.18.0-147.5.1.el8_1.x86_64
    [root@ecs-aece ~]# uname -a
    Linux ecs-aece 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
    [root@ecs-aece ~]# 

    2、lsb_release -a :查看distribution版本

    lsb_release -a

    效果

    [root@ecs-aece ~]# lsb_release -a
    LSB Version:    :core-4.1-amd64:core-4.1-noarch
    Distributor ID:    CentOS
    Description:    CentOS Linux release 8.0.1905 (Core) 
    Release:    8.0.1905
    Codename:    Core
    [root@ecs-aece ~]# 

    3、cat /etc/issue :查看distribution版本

    [root@ecs-aece ~]# cat /etc/issue
    S
    Kernel 
     on an m
    
    [root@ecs-aece ~]# 

    版本号含义
    linux内核版本有两种:稳定版(次版本为偶数)和开发版(次版本为奇数)
    版本号:主版本.次版本.释出版本-修改版本
    如:
    2.6.32-642.el6.x86_64
    3.10.0-693.17.1.el7.x86_64
    注:

    el 表示Enterprise Linux,6表示Centos6
    x86_64表示CPU结构,即64位
    一般用头两个数字(主次版本)描述内核系列
    释出版本:在主次版本架构不变的情况下,新增的功能累积到一定程度后释出的内核版本
    修改版本:修改一些bug等

    二、查看CUP

    cat /proc/cpuinfo

    [root@ecs-aece proc]# cat /proc/cpuinfo | grep "physical id" | uniq | wc -l
    1
    [root@ecs-aece proc]# cat /proc/cpuinfo | grep "cpu cores" | uniq
    cpu cores    : 1
    [root@ecs-aece proc]# cat /proc/cpuinfo | grep 'model name' |uniq
    model name    : Intel(R) Xeon(R) Gold 6266C CPU @ 3.00GHz
    [root@ecs-aece proc]# 
    [root@ecs-aece proc]# cat cpuinfo
    processor    : 0
    vendor_id    : GenuineIntel
    cpu family    : 6
    model        : 85
    model name    : Intel(R) Xeon(R) Gold 6266C CPU @ 3.00GHz
    stepping    : 7
    microcode    : 0x1
    cpu MHz        : 3000.000
    cache size    : 30976 KB
    physical id    : 0
    siblings    : 2
    core id        : 0
    cpu cores    : 1
    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 ss h
    t syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq 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 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat avx512_vnni md_clear flush_l1d arch_capabilitiesbugs        : spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit
    bogomips    : 6000.00
    clflush size    : 64
    cache_alignment    : 64
    address sizes    : 42 bits physical, 48 bits virtual
    power management:
    
    processor    : 1
    vendor_id    : GenuineIntel
    cpu family    : 6
    model        : 85
    model name    : Intel(R) Xeon(R) Gold 6266C CPU @ 3.00GHz
    stepping    : 7
    microcode    : 0x1
    cpu MHz        : 3000.000
    cache size    : 30976 KB
    physical id    : 0
    siblings    : 2
    core id        : 0
    cpu cores    : 1
    apicid        : 1
    initial apicid    : 1
    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 ss h
    t syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq 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 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat avx512_vnni md_clear flush_l1d arch_capabilitiesbugs        : spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit
    bogomips    : 6000.00
    clflush size    : 64
    cache_alignment    : 64
    address sizes    : 42 bits physical, 48 bits virtual
    power management:

    三、查看内存

    free

    [root@ecs-aece ~]# free
                  total        used        free      shared  buff/cache   available
    Mem:        7999932     5820776      226292      429116     1952864     1656500
    Swap:             0           0           0
    [root@ecs-aece ~]# free -h
                  total        used        free      shared  buff/cache   available
    Mem:          7.6Gi       5.6Gi       220Mi       419Mi       1.9Gi       1.6Gi
    Swap:            0B          0B          0B
    [root@ecs-aece ~]# free -m
                  total        used        free      shared  buff/cache   available
    Mem:           7812        5686         218         419        1907        1615
    Swap:             0           0           0
    [root@ecs-aece ~]# free -g
                  total        used        free      shared  buff/cache   available
    Mem:              7           5           0           0           1           1
    Swap:             0           0           0
    [root@ecs-aece ~]# 

    四、查看硬盘

    df 命令

    [root@ecs-aece proc]# df
    Filesystem     1K-blocks     Used Available Use% Mounted on
    devtmpfs         3984840        0   3984840   0% /dev
    tmpfs            3999964       12   3999952   1% /dev/shm
    tmpfs            3999964   342540   3657424   9% /run
    tmpfs            3999964        0   3999964   0% /sys/fs/cgroup
    /dev/vda1       41021664 14590644  24317536  38% /
    /dev/vdb       102687672   296252  97132156   1% /data
    tmpfs             799992        0    799992   0% /run/user/0
    overlay         41021664 14590644  24317536  38% /var/lib/docker/overlay2/89350792543f52e6481db408052501edffaf3c8b6cfbd7
    078097e65ac72a9b09/mergedoverlay         41021664 14590644  24317536  38% /var/lib/docker/overlay2/e69f29e313192fa11381de794c09311198b5f9925f379c
    2b85189b390dcfa902/mergedshm                65536        0     65536   0% /var/lib/docker/containers/8ad780f8ce389c37765b574865c51b1a7e87ec709275
    66ac759b1aa46bcfbbf2/mounts/shmshm                65536        0     65536   0% /var/lib/docker/containers/20dea4f17406dbc9a61984caa5e057d20523b20081ec
    bc827da9cb8e27d4ae4d/mounts/shmoverlay         41021664 14590644  24317536  38% /var/lib/docker/overlay2/39207a1af8a73d670737d706926fba03d1d609a3d0f9c0
    c57cdb1e38536ba64a/merged

    简单方式查看

    [root@ecs-aece proc]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        3.9G     0  3.9G   0% /dev
    tmpfs           3.9G   12K  3.9G   1% /dev/shm
    tmpfs           3.9G  335M  3.5G   9% /run
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/vda1        40G   14G   24G  38% /
    /dev/vdb         98G  290M   93G   1% /data
    tmpfs           782M     0  782M   0% /run/user/0
    overlay          40G   14G   24G  38% /var/lib/docker/overlay2/89350792543f52e6481db408052501edffaf3c8b6cfbd7078097e65ac
    72a9b09/mergedoverlay          40G   14G   24G  38% /var/lib/docker/overlay2/e69f29e313192fa11381de794c09311198b5f9925f379c2b85189b390
    dcfa902/mergedshm              64M     0   64M   0% /var/lib/docker/containers/8ad780f8ce389c37765b574865c51b1a7e87ec70927566ac759b1aa
    46bcfbbf2/mounts/shmshm              64M     0   64M   0% /var/lib/docker/containers/20dea4f17406dbc9a61984caa5e057d20523b20081ecbc827da9cb8
    e27d4ae4d/mounts/shmoverlay          40G   14G   24G  38% /var/lib/docker/overlay2/39207a1af8a73d670737d706926fba03d1d609a3d0f9c0c57cdb1e385
    36ba64a/merged

    fdisk 命令

    [root@ecs-aece proc]# fdisk -l
    Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xe67edd27
    
    Device     Boot Start      End  Sectors Size Id Type
    /dev/vda1  *     2048 83886079 83884032  40G 83 Linux
    
    
    Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    [root
    @ecs-aece proc]# fdisk -l | grep Disk Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors Disklabel type: dos Disk identifier: 0xe67edd27 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 sectors [root@ecs-aece proc]#

    iostat 查看硬盘读写速度

    [root@ecs-aece proc]# iostat
    Linux 4.18.0-147.5.1.el8_1.x86_64 (ecs-aece)     08/01/2020     _x86_64_    (2 CPU)
    
    avg-cpu:  %user   %nice %system %iowait  %steal   %idle
               4.22    0.02    0.74    0.05    0.00   94.97
    
    Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
    vda               2.59         3.20        81.39   10616445  269754716
    vdb               0.02         0.02         0.17      49937     559176
    
    [root@ecs-aece proc]# iostat -t 1 3
    Linux 4.18.0-147.5.1.el8_1.x86_64 (ecs-aece)     08/01/2020     _x86_64_    (2 CPU)
    
    08/01/2020 10:25:01 AM
    avg-cpu:  %user   %nice %system %iowait  %steal   %idle
               4.22    0.02    0.74    0.05    0.00   94.97
    
    Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
    vda               2.59         3.20        81.39   10616445  269759148
    vdb               0.02         0.02         0.17      49937     559176

    参考资料:

    linux内核版本号查看与含义

    Linux中常用的查看系统信息的命令

    Linux查看系统基本信息,版本信息(最全版)

    Linux iostat命令详解

    buff/cache 了解一下?

  • 相关阅读:
    BTree B+Tree
    SpringMvc框架 解决在RESTFUL接口后加任意 “.xxx” 绕过权限的问题
    多线程基础知识---sleep和wait区别
    多线程基础知识---join方法
    Maven跳过单元测试的两种方式
    maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令
    Maven项目版本继承 – 我必须指定父版本?
    SpringMVC 零配置 无web.xml
    利用ApplicationContextAware装配Bean
    Spring Boot 读取 resource 下文件
  • 原文地址:https://www.cnblogs.com/wangwangfei/p/13412597.html
Copyright © 2020-2023  润新知