top of page
Search

"/etc/issue" and "/etc/motd" in Linux: How to customize the tty before and after the login.

  • Writer: Chris
    Chris
  • Dec 25, 2024
  • 3 min read



Linux provides incredible opportunities for customization. While many users focus on desktop environments, there’s also significant potential in the command-line interface. Two crucial files that you can personalize are `/etc/issue` and `/etc/motd`. These files not only help display important system information but also let you add personal messages that showcase your unique style.


Understanding /etc/issue


The `/etc/issue` file shows a message before a user logs in. This message typically includes system identification details like the distribution name, version, and kernel version. It's often the first thing users see, making it an ideal place for important announcements or friendly greetings.


Customizing `/etc/issue` adds a personal touch and improves the user experience. For instance, you could display a welcome message along with key server information, such as load limits or uptime.


Customizing /etc/issue


To modify the `/etc/issue` file, you must have root or sudo privileges. You can use a text editor like `nano`, `vim`, or `gedit`. Follow these easy steps:


  1. Open the terminal.

  2. Enter `sudo nano /etc/issue` and press Enter.


After opening the file, you can change the message. Here’s an example of an effective customization:

Welcome to My Custom Linux Machine!
Kernel Version: $(uname -r)
Uptime: $(uptime -p)

Please login:

You can also make your message more engaging by using ANSI color codes. These codes can enhance visibility and aesthetics. For instance, to display the text in green, use `\e[32m` to start the colored message and `\e[0m` to reset the color.


Here’s the updated example with colors:

\e[32mWelcome to My Custom Linux Machine!\e[0m

Understanding /etc/motd


The `/etc/motd` (Message of the Day) file appears after a user successfully logs in. It serves as a platform for announcements, updates, and other important notes. This is an excellent spot to keep users informed on a recurring basis.


Common uses for `/etc/motd` include notifying users about system maintenance schedules, security reminders, or general greetings. According to a survey, 70% of users appreciate getting updates about system features and maintenance right after logging in.


Customizing /etc/motd


Like `/etc/issue`, modifying `/etc/motd` is straightforward with the right permissions. Here’s how you can add your custom messages:


  1. Open the terminal.

  2. Type `sudo nano /etc/motd` and press Enter.


Once you have access to the file, you might want to include content such as:

Welcome to Your Linux Server!
Server Maintenance: Every Sunday from 3 AM to 4 AM

Important Updates:
- New features added to enhance your workflow
- Reminder: update your passwords every 90 days

As with `/etc/issue`, you can also apply colors to your messages inside `/etc/motd`. Here’s a way to incorporate colors into your message:

\e[34m Welcome to Your Linux Server! \e[0m

Adding Some Flair with ASCII Art


One fun way to enhance both `/etc/issue` and `/etc/motd` is by using ASCII art. This can make your messages stand out and add a distinctive touch. Popular tools for generating ASCII art include `figlet` or `toilet`.


To get started with `figlet`, follow these steps:


  1. Install `figlet` using your package manager, for example: `sudo apt install figlet` on Ubuntu.

  2. Use `figlet` to create artistic text. Here’s a quick command:

figlet Welcome to Linux!

You can then take the ASCII output and add it to either `/etc/issue` or `/etc/motd`, making the experience both informative and visually appealing.


Testing Your Customizations


After customizing both files, testing is essential to confirm they display as intended. Simply log out and log back in, or open a new terminal session, to see your messages. If something doesn’t look quite right, recheck the ANSI escape sequences and any other formatting.


Common issues to watch for include missing resets for colors or incorrectly placed escape codes. A little troubleshooting can go a long way in achieving your desired look.


Enjoy Your New Setup


Whether you're managing a personal server or a network of machines, a little customization can be fun and by adding some scripts you can even live without login/display-managers.


Happy customization!

 
 
 

Recent Posts

See All
How to Use Chattr Command in Linux (for Beginners)

Chattr is a UNIX command-line program that’s pre-shipped in most Linux distributions. The role of this command is to allow the admin user to set file attributes that impose restrictions on files. Ther

 
 
 

Comments


bottom of page