分享一個查看CentOS系統資訊的指令碼

來源:互聯網
上載者:User

最近在看《實戰Linux Shell編程與伺服器管理》,一邊看一邊練習,看到sed和awk時感覺這兩個工具真是太好用了。學以致用,於是想平時想看看系統資訊,總是去查命令,然後去一堆資訊裡去找,不如寫個指令碼來練練手,於是就有了InfoView4CentOS這個指令碼。

代碼託管在Github也是來練習使用Github的),地址:https://github.com/callmepeanut/InfoView4CentOS

採用選單的方式,可以查看ip、硬體等資訊,運行效果如下:

[root@localhost InfoView4CentOS]# ./InfoView4CentOS.sh1) HostIp                 3) SystemVersion          5) NonDefault-LoginUsers2) HardwareInfo           4) OpenPorts              6) ExitPlease input your choice:

1)查看IP

Please input your choice:1===============NetworkInfo===============Host ip is: 10.0.2.15Please input your choice:

2)查看CPU、記憶體、硬碟空間、網卡等資訊

Please input your choice:2===============HardwareInfo===============ProductName: VirtualBoxCPU:         Intel(R) Pentium(R) Dual  CPU  E2140  @ 1.60GHzPhysicMem:   801408 kBDiskSpace:   12G 25%usedNetWorkCard: PCnet/PCI II 79C970APlease input your choice:

3)查看系統和核心版本

Please input your choice:3===============SystemInfo===============Release:         release 6.4 (Final)Kernal Version:  2.6.32-358.el6.i686System Bits:     32 BitPlease input your choice:

4)查看連接埠開放情況

Please input your choice:4===============OpenPortsInfo===============OpenPorts:  127.0.0.1:9000    1430/php-fpm    0.0.0.0:3306     1656/mysqld     0.0.0.0:139       1771/smbd     0.0.0.0:111    1103/rpcbind      0.0.0.0:80      1423/nginx      0.0.0.0:22       1815/sshd   127.0.0.1:631      1292/cupsd    127.0.0.1:25     1753/master     0.0.0.0:445       1771/smbd   0.0.0.0:46943  1187/rpc.statd   127.0.0.1:199      1416/snmpd          :::139       1771/smbd          :::111    1103/rpcbind           :::22       1815/sshd         ::1:631      1292/cupsd        :::60826  1187/rpc.statd          :::445       1771/smbd

5)查看非預設登入shell使用者

Please input your choice:5===============UsersInfo===============peanut:x:500:500:peanut:/home/peanut:/bin/bashmysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bashseg:x:502:502::/home/seg:/bin/bashPlease input your choice:

6)退出

Please input your choice:6Bye

輸入錯誤

Please input your choice:aBad ChoicePlease input your choice:


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.