Archive for September 26th, 2013

Resolving messed up console / terminal on GNU Linux / A tiny old school hack ;)

Thursday, September 26th, 2013

Resolve fix messed up unreadable gnu linux console terminal screenshot

Its probably not so common problem among new-comer Linux users / admins but sooner or later even those who haven't will cat by mistake (or on purpose) some binary file end result will be physical console / terminal / SSH Client (lets say PuTTY) will display some non-sense characters and whether typing you will type in some "alien language" characters this continues until you close up console and re-login. Of course its not such a big problem to re-login or (kill active SSH session).

fix terminal after showing displaying binary file by mistake catting wrong file incident

But there is no sense to do that and loose time and most importantly loose your logged in session (especially if you have hopped to 4 ssh sessions and you forgot to run GNU / screen). Thus its handy to know about
 

# reset

command. Once issued in most cases TTY messed up characters gets fixed up. However if even reset doesn't fix it, there is another "hack" to resolve it with no need for relogin. This is an old hack from my old Linux days and not so popular among admins, here is how:

Type

cat

press Enter

and then press

Ctrl + O (Ctrl ^ O)

 

then press Enter

and then again press

Ctrl + D (Ctrl ^ D)

Nice hack isn't it ? 🙂

Umounting Linux drive if it doesn’t want to unmount “umount: /media/cdrom: device is busy”

Thursday, September 26th, 2013

If you use Linux as Desktop or even on some servers you might end up in situation where mounted filesystem is refusing to unmount with an error:
 

umount: /media/cdrom: device is busy

That's pretty annoying and many people (especially) desktop users would force a system reboot in order to have the fs unmounted.

If this happened to you, there is no need for that anymore. umount cmd has a handy option – (Lazy Unmount) for situations like this. Here is -l description from umount manual:

 -l     Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon
              as it is not busy anymore.  (Requires kernel 2.4.11 or later.)

So next time you hit "umount device is busy" do:

# umount -l /media/cdrom

Enjoy 😉