Best way to find os name and version in Unix/Linux platform

后端 未结 9 891
天涯浪人
天涯浪人 2020-12-02 07:33

I need to find the OS name and version on Unix/Linux platform. For this I tried following:

  1. lsb_release utility

  2. /etc/redha

9条回答
  •  猫巷女王i
    2020-12-02 07:46

    I prepared following commands to find concise information about a Linux system:

    clear
    echo "\n----------OS Information------------"
    hostnamectl | grep "Static hostname:"
    hostnamectl | tail -n 3
    echo "\n----------Memory Information------------"
    cat /proc/meminfo | grep MemTotal
    echo "\n----------CPU Information------------"
    echo -n "Number of core(s): "
    cat /proc/cpuinfo | grep "processor" | wc -l
    cat /proc/cpuinfo | grep "model name" | head -n 1
    echo "\n----------Disk Information------------"
    echo -n "Total Size: "
    df -h --total | tail -n 1| awk '{print $2}'
    echo -n "Used: "
    df -h --total | tail -n 1| awk '{print $3}'
    echo -n "Available: "
    df -h --total | tail -n 1| awk '{print $4}'
    echo "\n-------------------------------------\n"
    

    Copy and paste in an sh file like info.sh and then run it using command sh info.sh

提交回复
热议问题