I recently read "Practical Linux Shell programming and Server Management" and practiced it. When I saw sed and awk, I felt that these two tools were really useful. After learning to use it, I want to see the system information at ordinary times. I always want to check the command and find it in a pile of information. It is better to write a script to train the trainer, so I have the InfoView4CentOS script.
Code hosting is also coming to practice using Github on Github), address: https://github.com/callmepeanut/InfoView4CentOS
You can view the ip address, hardware, and other information in the menu. The running effect is as follows:
[root@localhost InfoView4CentOS]# ./InfoView4CentOS.sh1) HostIp 3) SystemVersion 5) NonDefault-LoginUsers2) HardwareInfo 4) OpenPorts 6) ExitPlease input your choice:
1) view IP Address
Please input your choice:1===============NetworkInfo===============Host ip is: 10.0.2.15Please input your choice:
2) view CPU, memory, hard disk space, network card, and other information
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) view the system and kernel version
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) view port opening status
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) view non-default shell users
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) quit
Please input your choice:6Bye
Input error
Please input your choice:aBad ChoicePlease input your choice: