|NO.Z.00056|——————————|LinuxShell|——|Linux&Shell$变量.V13|——|shell终端|

一、shell登录信息
### --- /etc/issue
~~~     我们在登录 tty1-tty6 这六个本地终端时,会有几行的欢迎界面。
~~~     这些欢迎信息是保存在哪里的?
~~~     可以修改吗?当然可以修改,这些欢迎信息是保存在/etc/issue 文件中,
~~~     我们查看下这个文件:

[root@localhost ~]# cat /etc/issue
CentOS release 6.8 (Final)
Kernel \r on an \m

二、可以支持的转义符我们可以通过 man agetty 命令查询,在表中我们列出常见的转义符作用:

  作用
\d 显示当前系统日期
\s 显示操作系统名称
\l 显示登陆的终端号,这个比较常用
\m 显示硬件体系结构,如i386,i686等
\n 显示主机名
\o 显示域名
\r 显示内核版本
\t 显示当前系统时间
\u 显示当前登录用户的序列号

三、/etc/issue.net

### --- /etc/issue.net
~~~     /etc/issue 是在本地终端登录是显示欢迎信息的,
~~~     如果是远程登录(如 ssh 远程登录,或 telnet远程登录)需要显示欢迎信息,
~~~     则需要配置/etc/issue.net 这个文件了。使用这个文件时由两点需要注意:
~~~     首先,在/etc/issue 文件中支持的转义符,在/etc/issue.net 文件中不能使用。
~~~     其次,ssh 远程登录是否显示/etc/issue.net 文件中的欢迎信息,是由 ssh 的配置文件决定的。
~~~     如果我们需要 ssh 远程登录可以查看/etc/issue.net 的欢迎信息,
~~~     那么首先需要修改 ssh 的配置文件/etc/ssh/sshd_config,加入如下内容:
~~~     这样在 ssh 远程登录时,也可以显示欢迎信息,只是不再可以识别“\d”和“\l”等信息了

[root@localhost ~]# cat /etc/ssh/sshd_config
~~~     …省略部分输出…
no default banner path
Banner none
Banner /etc/issue.net
~~~     …省略部分输出…

四、/etc/motd

### --- /etc/motd

~~~     /etc/motd文件中也是显示欢迎信息的,
~~~     这个文件和/etc/issue 及/etc/issue.net 文件的区别是:
~~~     /etc/issue 及/etc/issue.net 是在用户登录之前显示欢迎信息,
~~~     而/etc/motd 是在用户输入用户名和密码,正确登录之后显示欢迎信息。
~~~     在/etc/motd 文件中的欢迎信息,不论是本地登录,还是远程登录都可以显示。

 

 

 

 

 

 

 

 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on 2022-03-26 23:26  yanqi_vip  阅读(2)  评论(0编辑  收藏  举报

导航