Linux allows us to display messages before and after login at CLI. To display messages before and after login it uses two separate files. It uses the /etc/issue file to display messages before login. To display a message after login, it uses the /etc/motd file.
Displaying banner before login
Linux uses the /etc/issue file to save a login banner or message the shell displays before login. By default, this file contains two options that display Linux and kernel versions. To display a customized message before login, you can edit this file.
Let's take an example.
Suppose you want to display the following message before the login prompt.
############################# Welcome to the Red Hat training program. Use the following credentials to log in. Username: your enrollment number Password: your first name ##############################
To display the above message on the login screen, open the /etc/issue file.
Add the above message after the default contents and save the file.
To verify the message, exit the current session. Linux displays this file's contents before the user logs in.
The /etc/issue file provides an excellent way to give specific log in instructions to users who are not logged in yet.
Displaying banner after login
Linux uses the /etc/motd file to save a login banner or message the shell displays after login. By default, this file is empty. To display a customized message after login, you can edit this file.
Let's take an example.
Suppose you want to display the following message after the login prompt.
############################# Please submit your enrollment form before Saturday. ##############################
To display the above message when a user logs in, open the /etc/motd file.
Add the above message to the file and save the file.
To verify the message, exit the current session and log in again.
Key points
- To display messages before and after the login process, Linux uses the /etc/issue and the /etc/motd files.
- These messages display on CLI. Users will not see these messages before and after a graphical login.
- The /etc/issue file is normally used to display a login message or banner.
- The /etc/motd file is generally used to display an issue, security policy, or message.
- These messages are global. These messages will display to all users at the CLI prompt.
- Only a privileged user (such as root) can edit these files.