14. Pretentious and practical skills --- set up a welcome speech for local and remote login to the server

content

1. Shell login information

2.man agetty command

3. Set the server login welcome

4./etc/motd

5. Define Bash shortcuts


1. Shell login information

1)/etc/issue

When we log in to the six local terminals tty1-tty6, there will be several lines of welcome information. These welcome messages are stored in the /etc/issue file, which we can view:

[root@localhost ~]# cat /etc/issue

CentOS release 6.5 (Final)

Kernel \r on an \m

2.man agetty command

We can query the supported escape characters through the man agetty command. We list the common escape characters in the table:

escape character

\d displays the current system date

\s displays the operating system name

\l Display the login terminal number (commonly used)

\m Display hardware system results, such as: i386, i686, etc.

\n Display hostname

\o Display domain name

\r show kernel version

\t Display current system time

\u Display the serial number of the currently logged in user

3. Set the server login welcome

As shown below;

/etc/issue is to display the welcome message when logging in at the local terminal. If the remote login (such as ssh remote login, or telnet remote login) needs to display the welcome message (warning message), you need to configure the file /etc/issue.net . There are two things to note when using this file:

First of all, the escape characters supported in the /etc/issue file cannot be used in the /etc/issue.net file. Secondly, whether the ssh remote login displays the welcome information in the /etc/issue.net file is determined by the ssh configuration file. If we need ssh remote login to view the welcome information of /etc/issue.net, then we first need to modify The ssh configuration file /etc/ssh/sshd_config adds the following content:

[root@localhost ~]# vim /etc/ssh/sshd_config    #打开配置文件
#Banner none                                    #找到次行内容模板
Banner /etc/issue.net                           #修改为此内容保存退出
[root@localhost ~]# vim /etc/issue          #打开配置文件,写入想要的欢迎语保存退出
[root@localhost ~]# systemctl restart sshd      #重启sshd服务即可

(Add the above content after #Banner none. In this way, the welcome message can also be displayed when logging in remotely through ssh, but the information such as \d and \l is no longer recognized. (Note that you need to restart the service shhd restart)

4./etc/motd

The welcome message is also displayed in the /etc/motd file. The difference between this file and the /etc/issue and /etc/issue.net files is: /etc/issue and /etc/issue.net display the welcome message before the user logs in. , and /etc/motd is to display a welcome message after the user enters the user's username and password to log in correctly. The welcome message in the /etc/motd file can be displayed either locally or remotely.

5. Define Bash shortcuts

[root@localhost ~]# stty -a

#查询所有快捷键

speed 38400 baud; rows 22; columns 73; line = 0;

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;

..........

Define the ctrl+p shortcut as forced termination, and the ^ character can be entered manually.

[root@localhost ~]# stty intr ^p

[root@localhost ~]# ^P

[root@localhost ~]# ^P

[root@localhost ~]# stty -a

speed 38400 baud; rows 22; columns 73; line = 0;

intr = ^P; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;

............

Force termination becomes ctrl+p

Guess you like

Origin blog.csdn.net/weixin_46659843/article/details/123838008