If you have a graphical display manager, you can notice date and time there, but I haven't seen such a thing when it comes to TTY. If I want to check the current time (or date) I have to log in. It's a little bit annoying, especially in the morning. 🙂
I know that I can add the two parameters \t
and \d
to /etc/issue
file, for time and date respectively, but this solution doesn't refresh the time.
I thought maybe there's a way to add a script to the /etc/issue , but I couldn't find anything useful.
Is there a way to add time/date to the prompt?
Best Answer
Idea #1 - Customizing agetty
This is just a rough idea but I believe if your system is making use of
systemd
then your login prompt is controlled by this service file:If you look through this file:
If you take a look at
agetty
's man page it takes variety of switches. Perhaps you could either customize the prompt thatagetty
shows or you could swap outagetty
for an alternative that does, or wrapagetty
with a script that would display the time/date.EDIT #1
This wasn't meant as a out of the box solution, it was a rough idea for doing something. In searching for this there isn't really any way to do what you want, easily. You'll have to either create a customized version of
agetty
or change to something else likemgetty
or something else entirely.Idea #2 - /etc/issue file
The only other method I can conceive of doing something like you want with the time/date being displayed would be to make use of the file
/etc/issue
. The contents of this file allows for a few macros to be displayed such as these:excerpt agetty man page
Here's an example of my ancient
/etc/issue
box from a Fedora Core 3 system, when I used to take he time to set things like this up.                        Â
The source of that file looks like this:
                               Â
The penguin was generated using the
linux_logo
command, specifically the classic (-c
) version.