Take the 2-minute tour ×
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

2 Answers 2

up vote 6 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."

The better would be to set checkwinsize activation in ~/.bashrc.

  • Activate : shopt -s checkwinsize
  • Passivate : shopt -u checkwinsize
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

 
discard

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.