zoukankan      html  css  js  c++  java
  • 查看CPU、内存、版本等系统信息

    一:查看CPU

    more /proc/cpuinfo | grep "model name"
    
    grep "model name" /proc/cpuinfo

    如果觉得需要看的更加舒服

    grep "model name" /proc/cpuinfo | cut -f2 -d:
    [root@php ~]# more /proc/cpuinfo | grep "model name"
    model name    : Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz
    model name    : Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz
    [root@php ~]# grep "model name" /proc/cpuinfo
    model name    : Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz
    model name    : Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz
    [root@php ~]# grep "model name" /proc/cpuinfo | cut -f2 -d:
     Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz
     Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz
    [root@php ~]#  

    二:查看内存

    grep MemTotal /proc/meminfo
    
    grep MemTotal /proc/meminfo | cut -f2 -d:
    
    free -m |grep "Mem" | awk '{print $2}'

    三:查看cpu是32位还是64位

    查看CPU位数(32 or 64)

    [root@php ~]# getconf LONG_BIT
    64
    [root@php ~]# echo $HOSTTYPE
    x86_64
    [root@php ~]# uname -a
    Linux php.viroyaltest.com 3.10.0-1062.1.1.el7.x86_64 #1 SMP Fri Sep 13 22:55:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    [root@php ~]# 

    四:查看当前linux的版本

    [root@php ~]# more /etc/redhat-release 
    CentOS Linux release 7.6.1810 (Core) 
    [root@php ~]# cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core) 
    [root@php ~]# 

    五:查看内核版本

    [root@php ~]# uname -r
    3.10.0-1062.1.1.el7.x86_64
    [root@php ~]# uname -a
    Linux php.viroyaltest.com 3.10.0-1062.1.1.el7.x86_64 #1 SMP Fri Sep 13 22:55:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    [root@php ~]# 

    六:查看当前时间

    [root@php ~]# date
    Wed May  6 17:50:34 CST 2020
    [root@php ~]# 

    七:查看硬盘和分区

    [root@php ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        1.9G     0  1.9G   0% /dev
    tmpfs           1.9G     0  1.9G   0% /dev/shm
    tmpfs           1.9G   65M  1.8G   4% /run
    tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/vda1        40G  7.8G   30G  21% /
    tmpfs           379M     0  379M   0% /run/user/0
    tmpfs           379M     0  379M   0% /run/user/1000
    [root@php ~]# fdisk -l
    
    Disk /dev/vda: 42.9 GB, 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
    Disk label type: dos
    Disk identifier: 0x000af5dd
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048    83886079    41942016   83  Linux
    [root@php ~]# 

    可以看到全部占用的空间

    [root@php /]# du -sh      查看当前目录空间
    du: cannot access ‘./proc/5242/task/5242/fd/4’: No such file or directory
    du: cannot access ‘./proc/5242/task/5242/fdinfo/4’: No such file or directory
    du: cannot access ‘./proc/5242/fd/3’: No such file or directory
    du: cannot access ‘./proc/5242/fdinfo/3’: No such file or directory
    7.8G    .
    [root@php /]# du /etc -sh   查看指定目录空间
    39M    /etc
    [root@php /]# du -h --max-depth=1 /  查看/目录下每个文件的空间
    16K    /lost+found
    0    /dev
    39M    /etc
    65M    /run
    3.8G    /usr
    4.0K    /srv
    200M    /CloudResetPwdUpdateAgent
    1014M    /opt
    74M    /path
    6.1M    /home
    0    /sys
    365M    /root
    534M    /var
    4.0K    /mnt
    1.7G    /data
    du: cannot access ‘/proc/5318/task/5318/fd/4’: No such file or directory
    du: cannot access ‘/proc/5318/task/5318/fdinfo/4’: No such file or directory
    du: cannot access ‘/proc/5318/fd/3’: No such file or directory
    du: cannot access ‘/proc/5318/fdinfo/3’: No such file or directory
    0    /proc
    2.3M    /CloudrResetPwdAgent
    4.0K    /media
    116K    /tmp
    208M    /boot
    7.8G    /
    [root@php /]# 

    八:查看安装的软件包

    查看系统安装的时候装的软件包

    cat -n /root/install.log
    
    more /root/install.log | wc -l

    查看现在已经安装了那些软件包

    [root@php /]# rpm -qa
    libXdamage-1.1.4-4.1.el7.x86_64
    libssh2-1.8.0-3.el7.x86_64
    libXt-devel-1.1.5-3.el7.x86_64
    ncurses-base-5.9-14.20130511.el7_4.noarch
    libXinerama-1.1.3-2.1.el7.x86_64
    rpm-python-4.11.3-40.el7.x86_64
    urw-base35-z003-fonts-20170801-10.el7.noarch
    e2fsprogs-libs-1.42.9-16.el7.x86_64
    basesystem-10.0-7.el7.centos.noarch
    .
    .
    .
    .
    [root@php /]# rpm -qa | wc -l
    691
    [root@php /]# yum list installed | wc -l
    691
    [root@php /]# 

    九:查看键盘布局

    cat /etc/sysconfig/keyboard
    
    cat /etc/sysconfig/keyboard | grep KEYTABLE | cut -f2 -d=

    十:查看selinux情况

    [root@php /]# sestatus
    SELinux status:                 disabled
    [root@php /]# sestatus | cut -f2 -d:
                     disabled
    [root@php /]# 

    十一:查看ip,mac地址

    在ifcfg-eth0 文件里你可以看到mac,网关等信息。

    [root@node2 ~]# ifconfig
    br-8cf1758f9112: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
            inet6 fe80::42:72ff:fe39:ef18  prefixlen 64  scopeid 0x20<link>
            ether 02:42:72:39:ef:18  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    br-dd12bfd88f23: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
            ether 02:42:e6:e9:88:3d  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
            ether 02:42:bb:f9:f7:86  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.1.211  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fe80::a7c5:38ce:c1bd:7f88  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:42:49:f0  txqueuelen 1000  (Ethernet)
            RX packets 2988  bytes 239919 (234.2 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 121  bytes 14059 (13.7 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 64  bytes 5472 (5.3 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 64  bytes 5472 (5.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    [root@node2 ~]# 
    [root@node2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 | grep IPADDR
    IPADDR=192.168.1.211
    [root@node2 ~]# 
    [root@node2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 | grep IPADDR | cut -f2 -d=
    192.168.1.211
    [root@node2 ~]# 
    ifconfig
    
    cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR
    
    cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut -f2 -d=
    
    ifconfig eth0 |grep "inet addr:" |awk '{print $2}'|cut -c 6-
    
    ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'

    查看网关

    cat /etc/sysconfig/network

    查看dns

    [root@node2 ~]# cat /etc/resolv.conf
    # Generated by NetworkManager
    search test.com
    nameserver 8.8.8.8
    nameserver 8.8.8.4
    [root@node2 ~]# 

    十二:查看默认语言

    [root@node2 ~]# echo $LANG $LANGUAGE
    en_US.UTF-8
    [root@node2 ~]# cat /etc/sysconfig/i18n
    cat: /etc/sysconfig/i18n: No such file or directory
    [root@node2 ~]# 

    十三:查看所属时区和是否使用UTC时间

    timedatectl 命令
    
    (1) 读取时间,查看时间的各种状态
    
    timedatectl #等同于 timedatectl status
    
    (2) 设置时间
    
    timedatectl set-time "YYYY-MM-DD HH:MM:SS"
    
    (3) 列出所有时区
    
    timedatectl list-timezones
    
    (4) 设置系统时区为上海
    
    timedatectl set-timezone Asia/Shanghai
    
    (5) 是否NTP服务器同步
    
    timedatectl set-ntp yes #yes或者no
     
    ntpdate -u ntp.api.bz   #同步网络时间
    
    (6) 将硬件时钟调整为与本地时钟一致
    
    timedatectl set-local-rtc 1
    hwclock --systohc --localtime #与上面命令效果一致

    注意: 硬件时钟默认使用UTC时间,因为硬件时钟不能保存时区和夏令时调整,修改后就无法从硬件时钟中读取出准确标准时间,因此不建议修改。

    十四:查看主机名

    [root@node2 ~]# hostname
    node2.test.com
    [root@node2 ~]# cat /etc/sysconfig/network
    # Created by anaconda
    [root@node2 ~]# 

    修改主机名就是修改这个文件,同时最好也把host文件也修改

    [root@php ~]# more /proc/cpuinfo | grep "model name"model name: Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHzmodel name: Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz

  • 相关阅读:
    linux常用命令---文件操作
    Django 框架中定时触发脚本
    jquery 中选择当前标签下众多相同子标签中的第n个
    Django + DRF + Elasticsearch 实现搜索功能
    django 使用celery 实现异步任务
    python 通过 pymysql模块 操作 mysql 数据库
    django 自定义中间件 middleware
    django 使用其自带的验证系统 进行用户名有效性验证 登录状态验证 登入操作 登出操作
    python脚本 读取excel格式文件 并进行处理的方法
    python 将json格式的数据写入csv格式的文件中
  • 原文地址:https://www.cnblogs.com/is-possible/p/12838089.html
Copyright © 2011-2022 走看看