I have an Ubuntu 12.04 system where I, at reboot, login a root. This morning I did the things I had to and thought about running

apt-get -y upgrade

I started typing this but before pressing Enter I looked at the screen to check for mistyping things, and did see the cursor (blinking underscore) a few spaces after the final e like this (without the actual blinking):

apt-get -y upgrade    _

I definately did not type any spaces after the final e. After that I did just press Enter and apt-get ran fine.

I have often seen this happen before and would like to know what might cause this, in order to prevent it from happening again. Alternatively some way to reset this would also be acceptable.

Some details:

  • I tried stty sane, that did not change anything.
  • Before the apt-get command I did run a mount and w. The change happened between starting to type apt... and the final e
  • This was on tty2. When I logged out the cursor at the login: prompt was not at the position, but a few positions off on as well.
  • Switching to tty1, where I was not logged in, showed the cursor at the wrong position as well.
  • I switched back to the GUI (Alt+F7) and back to tty2 and the cursor was still off.
  • After looking at tty2 a minute or two later (while writing this Q and wanting to check something) the login: prompt was still there but now the cursor was at the right position.
  • I tried to recreate the problem by issuing the same commands (but with different amounts of time between them as before, now directly after each other) and could not get the cursor to bulge from the normal position.
  • echo $TERM gives linux
  • echo $PS1 gives ${debian_chroot:+($debian_chroot)}\u@\h:\w\$

This would not bother me so much, but it has happened quite often. When just typing commands it is not such a problem, but it completely confuses me, when it happened and I want to edit some previous command (bash), as then the insertion point is a few positions left from the blinking cursor.

How can I reset the cursor to the right position when this happens? Or preferably: how to prevent this from happening?

  • 1
    Does your prompt correctly protect any control sequences with \[…\]? Is TERM correct? Commented Feb 10, 2014 at 8:42
  • @gilles I don't have any \[..\] in the prompt. And $TERM is linux ( I updated the details list with these two).
    – Timo
    Commented Feb 10, 2014 at 9:07
  • Your $TERM and $PS1 are the same as mine. Did you type any commands longer than the tty width of 80 characters and/or delete back to the previous line?
    – Harold
    Commented Feb 10, 2014 at 9:13
  • @Harold I tried with a long line until I got to the next and Backspaced back to the previous. That did not cause it (and I sure did not do that the last time the cursor 'moved'.
    – Timo
    Commented Feb 10, 2014 at 9:18
  • Maybe you need \[…\], that's the point. Is your prompt in color? Copy-paste your PS1 assignment, or the output of printf '%s\n' $PS1 | cat -v Commented Feb 10, 2014 at 10:34

1 Answer 1


The problem is caused by systemd-fsck printing '\r' to /dev/console. The terminal tty1 thus must wait until systemd-fsckd is inactive. My preliminary fix on my Ubuntu 18.04.4 system involves a file /etc/systemd/system/[email protected]/override.conf:


ExecStart=-/usr/local/bin/delaytty1.sh $TERM

The script /usr/local/bin/delaytty1.sh reads:

while [ $a = "active" ]; do
sleep 1
a=$(/bin/systemctl is-active systemd-fsckd.service)
/sbin/agetty --noclear tty1 $1
  • Ubuntu 12 didn't use systemd.
    – JdeBP
    Commented Sep 12, 2020 at 2:39

You must log in to answer this question.

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