It's so over...😞

Customizing the Linux TTY

August 12, 2022


I recently discovered how stupidly easy it is to customize your TTY login prompt. Obviously this knowledge will only apply to startx chads, but it’s not too difficult to migrate away from a login manager if you really want to do this. It surprises me that I don’t see more .jpgs of riced prompts, since the folks using startx tend to be a little more technically literate, I think. But anyways, let’s get started.

Setting a Custom Font

If you haven’t already, you might enjoy the look of using a custom font. While you’re still in the TTY, you can run setfont $FONTNAME to change the font of the terminal. Most likely, your console-specific fonts will be stored in /usr/share/kbd/consolefonts/. Using the setfont command only invokes temporary changes; permanent font changes are done in the /etc/vconsole.conf file. If you don’t have this file on your system already, you can create it and add the following: FONT=sun12x22.psfu.gz. I chose Sun Gallant Demi, because it is objectively the best console font. Luxi Mono is pretty close stylistically, if you want something you can use outside of the TTY. To set the default font, replace sun12x22.psfu.gz with the name of the font you want to use. Specifying the directory is unnecessary, unless the font you want to use is stored outside of the kbd folder. You can also set a keymap in vconsole.conf by adding KEYMAP=$KEYMAP, and it is set to us by default.

To finalize your changes and have the font load on startup, be sure to add consolefont to your mkinitcpio hooks and rebuild.

Customizing the Login Prompt

By default, agetty will process the contents of /etc/issue when you land at the TTY. If you don’t have this file already you can create it by doing a touch /etc/issue. As a personal preference, I like to clear the contents of the screen at landing (i.e., the wall of text your OS generates during startup). You can invoke this by inserting a “clear” escape sequence in the first line of your issue file by running clear > /etc/issue. This will destroy any existing /etc/issue file and insert the characters ^[[H^[[2J at the first line of the new file. When you edit the file from now on, be sure not to change the first line. A screenshot of my machine’s issue file is below. Notice how I have a few empty lines at the top and bottom of the file for formatting and pleasant looks.

My Machine’s Issue File

If you tried putting some ASCII art in your issue file as I did, you will soon discover that a lot of ASCII art is probably be too big to fit on your screen (in the TTY, anyways). The number of lines you’ll have to work with will depend on your font size and screen resolution. Just play around with it and see what works. There are a couple sites out there that have large ASCII collections, or you could use a text-to-ASCII art generator to display a simple message in an aesthetically-pleasing fashion.

Escape Codes

Issue files can contain a number of escape codes, which display variable information about your system. All escape codes are comprised of a backslash followed by one of several characters. From man agetty:

For example, my /etc/issue file reads as:

ARTIX LINUX ROLLING \r [\m] | \n @ \4{wlp3s0}

And when I boot the machine, it displays as:

ARTIX LINUX ROLLING 5.15.52-1-lts [x86_64] | illumina @ 192.168.x.xx

The Message of the Day

As the /etc/issue file is displayed before you login, agetty can also display a “Message of the Day”, or MOTD, after you login. I personally don’t make use of a MOTD, because I have X launch immediately upon logging in, but this could be useful on a server that regularly gets SSH’d into by multiple people. MOTD configuration is done in the /etc/motd file. Any text entered in this file is displayed automatically after login. It will also recognize and process the same escape codes that can be called in the /etc/issue file. You can also use the /etc/update-motd.d directory to call scripts on login, appending their output to the MOTD. The scheme for naming scripts is NN-scriptname, where NN is any number from 0 to 99. Scripts will run in order, beginning at the lowest number and working up to the highest number.


📬Reply via E-Mail or Share with a friend.

Tagged:
Technology · Linux
[RSS] [Share]