Bash 脚本实现每次登录到 Shell 时可以查看 Linux 系统信息( 二 )

把上面脚本内容保存到一个文件 system-info.sh,之后添加可执行权限:
# chmod +x ~root/system-info.sh当脚本准备好后,把脚本文件的路径加到 .bash_profile 文件末尾(红帽系列的系统:CentOS、Oracle Linux 和 Fedora):
# echo "/root/system-info.sh" >> ~root/.bash_profile执行以下命令,来让修改的内容生效:
# source ~root/.bash_profile对于 Debian 系统的系统,你可能需要把文件路径加到 .profile 文件中:
# echo "/root/system-info.sh" >> ~root/.profile运行以下命令使修改生效:
# source ~root/.profile你以前运行上面 source 命令时可能见过类似下面的输出 。从下次开始,你在每次登录 shell 时会看到这些信息 。当然,如果有必要你也可以随时手动执行这个脚本 。
-------------------------------System Information---------------------------Hostname: daygeek-Y700uptime: 1:20 1Manufacturer: LENOVOProduct Name: 80NVVersion: Lenovo ideapad Y700-15ISKSerial Number: AA0CMRN1Machine Type: PhysicalOperating System: Manjaro LinuxKernel: 4.19.80-1-MANJAROArchitecture: x86_64Processor Name: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHzActive User: daygeek renu thanuSystem Main IP: 192.168.1.6 192.168.122.1-------------------------------CPU/Memory Usage------------------------------Memory Usage: 37.28%Swap Usage: 0.00%CPU Usage: 15.43%-------------------------------Disk Usage >80%-------------------------------Filesystem Size Used Avail Use Mounted on/dev/nvme0n1p1 217G 202G 4.6G 98 //dev/loop0 109M 109M 0 100 /var/lib/snapd/snap/odrive-unofficial/2/dev/loop1 91M 91M 0 100 /var/lib/snapd/snap/core/6405/dev/loop2 90M 90M 0 100 /var/lib/snapd/snap/core/7713-------------------------------For WWN Details-------------------------------CentOS8.2daygeek.com is a VM-------------------------------Oracle DB Instances---------------------------oracle user does not exist on CentOS8.2daygeek.com-------------------------------Package Updates------------------------------- 13 Security notice(s) 9 Important Security notice(s) 3 Moderate Security notice(s) 1 Low Security notice(s) 35 Bugfix notice(s) 1 Enhancement notice(s)-----------------------------------------------------------------------------


推荐阅读