Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sometimes, a terminal screen is messed up, and when we use man ls to read the manpages, or press the UP arrow to go to previous commands in history, the screen will show characters not as the right place. (for example, treat the end of screen as some where in the middle of the screen).

The command reset is tried and it wouldn't work. One way that works is to log out or close the window, and resize the window first, and then do ssh (or close that tab, and resize the window, and then open a new tab to get a new shell).

But this way, we will lose anything that we previously did, such as starting a virtual machine console, etc. So if we don't close the shell, is there a way to fix this problem?

(this happened before right inside Fedora, and also for a Macbook ssh into a RHEL 5.4 box).

Update: I remember now how it happened in Fedora: I opened up a Terminal, and did a FreeVM to use a console of a Virtual Machine (a shell). I think it was size 80 x 25 and then after a while, I resized the Terminal to 130 x 50 approximately, and then the "inner shell" (of the VM) started to behave weird).

share|improve this question
What terminal emulator are you using? Sounds broken if reset doesn't resolve the issue. – jordanm Jan 17 '13 at 5:54
whatever Terminal program inside of Fedora... and the default Terminal program on Mac OS X Lion. – 太極者無極而生 Jan 17 '13 at 7:38
Please see update above for how it happened in Fedora – 太極者無極而生 Jan 17 '13 at 19:32
The magical incantation is ^Jreset^J, where ^J means pressing ctrl-J. Or (on graphical terminals) you can try the Reset button. Also, some programs just aren't prepared for terminal sizes changing underneath them (yes, ancient software is alive and kicking) or just misbehave badly when the terminal gets too small. – vonbrand Jan 21 '13 at 19:29
@vonbrand: after not finding that in any answer, I'd suggest you post it as one. This has helped me many times. Personally I found it on commandlinefoo. – 0xC0000022L Mar 23 at 22:45

4 Answers 4

up vote 21 down vote accepted

If you are using bash, check if "checkwinsize" option is activated in your session using

shopt | grep checkwinsize

If you don't get

checkwinsize    on

then activate it with

shopt -s checkwinsize

Bash documentation says for "checkwinsize" attribute :

"If set, Bash checks the window size after each command and, if necessary, updates the values of LINES and COLUMNS."

If you like the setting, you could activate checkwinsize in your ~/.bashrc.

  • To activate: shopt -s checkwinsize
  • To deactivate: shopt -u checkwinsize
share|improve this answer
This doesn't happen to solve my problem, but this is a good general answer, so +1 anyway. I think my problem relates to Windows emulation(?) when ssh-ing into a Linux server. – geneorama Mar 19 at 15:21

I had the same problem as you and this is what I did:
I have a .profile setup in my user, so that is where I do all my changes.

There is a package called xterm which is available through apt-get I don't know about yum. But I did a local install from source as I do not have installation privileges. LINK:

./configure --prefix=/the/path/you/want/to/install/to
make install

I exported the path in my profile and invoked it at the same place

export PATH=$PATH:/the/path/you/want/to/install/to

So now every time I log in, the terminal size is set accordingly by resize.

share|improve this answer

I just wanted to add to what Arcadien had already mentioned. The checkwinsize enabling does the trick, but for me, what was needed was to reset the size of the window for it to work properly. I guess the checkwinsize was meant to eliminate this, but still, worth a shot. Just try changing the size of the window or un-maximizing and maximizing it post this option.

share|improve this answer

You can try Ctrl+L. It clears and/or redraws the terminal screen, depending on the program.

share|improve this answer
but it doesn't permanently solve the problem... – 太極者無極而生 Jan 17 '13 at 7:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.