登录前设置文件
登录后设置文本
登录后设置脚本
1、预登录信息和识别文件
[root@centos7 ~]# cat /etc/issue
\S
Kernel \r on an \m
Hostname: \n
展示为:
可根据参数自定义
\d 本地端时间的日期
\l 显示第几个终端机的接口
\n 显示主机的网络名称
\o 显示 domain name
\r 操作系统的版本 (类似 uname-r)
\t 显示本地端时间的时间
\s 操作系统的名称
\v 操作系统的版本
\r 详细的内核版本
\m 给出当前操作系统的位数
2、/etc/motd登录后提示信息
不可编辑命令类,只能定义为文本,如提示信息
[root@centos7 ~]# cat /etc/motd
Welcome to Linux
3、自定义登录后提示信息
在/etc/profile.d下创建对应bash文件如/etc/profile.d/welcome.sh
[root@centos7 ~]# cat /etc/profile.d/welcome.sh
#!/bin/bash
#
BEGINCOLOR="\e[1;35m"
ENDCOLOR="\e[0m"
echo -e "My hostname is ${BEGINCOLOR}`hostname`$ENDCOLOR"
echo -e "IP address is ${BEGINCOLOR} `ifconfig ens33 |grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|head -n1 ` $ENDCOLOR"
echo -e "OS version is ${BEGINCOLOR} `cat /etc/redhat-release ` $ENDCOLOR"
echo -e "CPU type is ${BEGINCOLOR}`lscpu|grep "Model name" |cut -d: -f2|tr -s " " `$ENDCOLOR"
echo -e "Kernel version is ${BEGINCOLOR} `uname -r ` $ENDCOLOR"
echo -e "Memtotol is ${BEGINCOLOR} `cat /proc/meminfo |head -n1 |grep -Eo '[0-9]+.*' `$ENDCOLOR"
echo -e "Disk space is ${BEGINCOLOR} `lsblk |grep 'sda\>' |grep -Eo '[0-9]+[[:upper:]]' ` $ENDCOLOR"
[root@centos7 ~]# clear
启动脚本执行顺序
/etc/issue > /etc/motd > cat /etc/profile.d/welcome.sh
Last login: Tue Oct 1 17:07:21 2019 from 192.168.146.1
Welcome to Linux # /etc/motd
My hostname is centos7.abc #/etc/profile.d/welcome.sh
IP address is 192.168.146.129
OS version is CentOS Linux release 7.6.1810 (Core)
CPU type is Intel(R) Core(TM) i7-6300HQ CPU @ 3.30GHz
Kernel version is 3.10.0-957.27.2.el7.x86_64
Memtotol is 995880 kB
Disk space is 200G
.el7.x86_64
Memtotol is 995880 kB
Disk space is 200G