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?

2 Answers 2


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:

/lib/systemd/system/[email protected]

If you look through this file:

$ grep -i exec /lib/systemd/system/[email protected] 
ExecStart=-/sbin/agetty --noclear %I 38400 linux

If you take a look at agetty's man page it takes variety of switches. Perhaps you could either customize the prompt that agetty shows or you could swap out agetty for an alternative that does, or wrap agetty with a script that would display the time/date.


Q: I checked agetty man, but there's no info as to displaying time/date in real time.

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 like mgetty 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

       The issue-file (/etc/issue or the file set with the -f option) may 
       contain certain escape codes to display the system name, date  and
       time etc. All escape codes consist of a backslash (\) immediately 
       followed by one of the letters explained below.

       d      Insert the current date.
       s      Insert the system name, the name of the operating system.
              Same as `uname -s'.
       m      Insert the architecture identifier of the machine. Same as 
              `uname -m'.
       n      Insert the nodename of the machine, also known as the 
              hostname. Same as `uname -n'.

       o      Insert the NIS domainname of the machine. Same as 
              `hostname -d'.
       r      Insert the release number of the OS. Same as `uname -r'.
       t      Insert the current time.

       Example: On my system, the following /etc/issue file:

              This is \n.\o (\s \m \r) \t

       displays as

              This is thingol.orcan.dk (Linux i386 1.1.9) 18:29:30

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.

                         ss #1

The source of that file looks like this:

                                ss #2

The penguin was generated using the linux_logo command, specifically the classic (-c) version.

  • I checked agetty man, but there's no info as to displaying time/date in real time. Feb 17, 2014 at 13:46
  • I think it's too complicated for me, so maybe I'd better stay with the enter pseudo solution Feb 18, 2014 at 3:51
  • I mentioned about \t and \d options in the /etc/issue file in the question. I also use linuxlongo to generate the debian logo. I don't know why it's so hard to put time/date in tty prompts, and I think there's no better solution but using /etc/issue file with \t and \d options and refresh them via enter. :) Feb 18, 2014 at 11:47
  • @MikhailMorfikov - yeah I know you knew these, I was attempting to make my answer more well rounded (covering every method I can conceive of) and also an affirmation that the /etc/issue outside of something custom, is likely the only option. I don't hink it's b/c of difficulty that there is no other option, ppl generally login to a GUI not a console is the real reason.
    – slm
    Feb 18, 2014 at 12:36
  • 1
    agetty can take a -t <n> option. If so, it restarts every <n> seconds. So I've entered -t 10 in /lib/systemd/system/[email protected]. And then use \t and \d in /etc/issue. Now the time updates every 10 seconds. Downside: If the user is in the middle of entering his username when the 10 second timeout occurs, it will be lost. He'll have to enter it again. Aug 5, 2015 at 23:04

You can change the prompt in shells by setting the variable PS1

bash allows several predefined identifiers \d adds the date, and \D{FORMAT} adds time with format. example \D{%H:%M:%S} will print the time (hours mins seconds).

It is worth checking what your current prompt is set to and set it just by hand until you are satisfied, then update your .bashrc file which is what sets it up on my system (Ubuntu).

To see what your current PS1

echo $PS1

To set it

PS1='\u@\h:\w \D{%H:%M:%S} \$ '

  • 1
    This isn't actually what I wanted. I want to check time/date without logging into TTY. Let's say, you have system without X-server, and you aren't logged in into the system, or you just logged out. You see just TTY prompt, and I want to see also time/date there. Feb 17, 2014 at 10:12
  • 2
    so you mean Login prompt ? well I have \d \t in /etc/issue and yes it doesn't update, but if I press enter at the prompt it is redisplayed and updated. The program running the prompt is getty when you type a name it will ask for a password, setting a timeout eg for 60 seconds -t60 to getty will timeout after 60 seconds at password prompt and will re-display issue file again.
    – X Tian
    Feb 17, 2014 at 11:15
  • Hmmm, I didn't know about the enter feature, but it seems to work. It's a little bit weird, but if there's no other way to refresh the time, I think I can live with that. I tried also the -t 60 parameter, but it refreshes also the prompt, so if you type your name and wait 60s, it will disappear. Feb 18, 2014 at 2:44
  • @Mikhail, if it seems to work could you tick answer - tks.
    – X Tian
    Feb 18, 2014 at 11:04
  • I give you up, but I'll leave this question open. Maybe there will be someone who knows a better answer to the question. Feb 18, 2014 at 11:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .