How to Manage or edit pre-login console messages using /etc/issue file
If you have ever visited the console mode of your Linux(press Ctrl+Alt+F1) you would have noted some message above the login prompt. These messages are mentioned in the /etc/issue or /etc/issue.net file. The file doesn't only work for plain text but various escape characters and terminal escape sequences can be included too.
I am running Ubuntu 10.10 now and the output of /etc/issue is
[shredde12]$ cat /etc/issue
Ubuntu 10.10 \n \l
The plain text part "ubuntu 10.10" is printed as it is and the escape sequences have special meanings,e.g \n stands for the hostname and \l for the tty name. Rest of the escape sequences and their options are.
| b | Insert the baudrate of the current line. |
| d | Insert the current date. |
| s | Insert the system name, the name of the operating system. |
| l | Insert the name of the current tty line. |
| m | Insert the architecture identifier of the machine, e.g., i686. |
| n | Insert the nodename of the machine, also known as the hostname. |
| o | Insert the domainname of the machine. |
| r | Insert the release number of the kernel, e.g., 2.6.11.12. |
| t | Insert the current time. |
| u | Insert the number of current users logged in. |
| U | Insert the string "1 user" or "n users" where n is the number of current users logged in. |
| v | Insert the version of the OS, e.g., the build-date etc. |
Using them you can create more useful login messages - showing time, number of users logged in, kernel version etc.
You can also go for terminal escape sequences. What are these? Remember the article on changing terminal colours. There we discussed escape sequences to configure colours of the terminal. Such characters, better known as terminal escape sequences are special codes recognized by the terminal. We can even use such characters in the /etc/issue file to get desired results.
Lets take the example of "clear" command. So, if we want a cleared screen before the login prompt i.e. nothing but the prompt, then we can either leave the file empty( but this may not be enough to ensure a clear screen) or we can embed the "clear" command code in the file. But, how would I do that? Try doing something like this,
[root]# clear > /etc/issue
If you think logically, the above command should store the output of "clear" command into the file /etc/issue. But the output of clear is an empty screen. How does that look like when written to a file? Open the file in vim, you will see these characters.
^[[H^[[J
The "^[" is the ascii representation of an Esc characters. The code is a terminal escape sequence. Try printing the file on the screen.
[shredder12]$ cat /etc/issue
It will act as a "clear" command. Pretty cool, isn't it?
So, if you go to the console now (ctrl+alt+f1) and press ENTER instead of typing the username, you will see the change automatically.
Lets try something familiar here. In case you don’t remember, we used the terminal escape sequences to change the colour paramters of the terminal. We can use the same logic to use the colour of our choice in the console.
Lets add a few more characters to the /etc/issue file
^[[1;31mUbuntu 10.10 \n \l ^[[0m
If you remember a bit, the changes are pretty straightforward. We changed the font colour to red using "[1;31m" and then reset it at the end using "[0m". Once again, “^[“ is the ascii form of Esc key (press Ctrl+V followed by Esc to get this character on Vim). If you still have doubts, refer to the terminal colours article where we discussed them.
So, that's how you play with the pre-login messages :).





leading to firefox slowing down. So, I was forced to close down a few firefox windows. I hated that because I never get an option to save those tabs. And this might happen to you as well.





















Post new comment