cat'ing a binary messes up terminal - why?
Thomas Sprinkmeier
thomas.sprinkmeier at gmail.com
Sat Oct 28 02:16:10 CST 2006
On Sat, 2006-10-28 at 10:53 +0930, Ben Petering wrote:
> Hi list,
>
> I have a query, not important, I'm just curious. Hopefully someone
> understands what's happening here.
>
> If I say
> $ cat /bin/login
>
> for example, my terminal gets all messed up - i.e. typing '/bin/login'
> now appears as
>
> $ /␉␋┼/┌⎺±␋┼
>
> I suppose some kind of character table translation is broken or
> something... can someone explain in detail why this happens? I NEED to
> know :)
Hi Ben,
Terminals support all sorts of escape sequences to do things like
scroll, jump, change colour and, as you've found, character set.
Catting a binary file can randomly activate these things.
There are even some exploits based on specially crafted binary files, so
be careful :-)
"less" is a safer choice than "cat", "hexdump" is safer still.
The "reset" command can fix the mess. Failing that, just close the
terminal and start anther one.
Thomas
More information about the linuxsa
mailing list