A bit about

Hello, everyone! All you can see below is just my bank of information. Some material I've found in the fathomless net, some I've learned myself. Don't think all of the information here is right or actual, but may be it could be of use for you :) All feedback is welcome, especially constructive ones :)

Wednesday, January 27, 2010

VIM: Numpad doesn't work in PuTTY

If I work on Windows I usually use PuTTY to connect to remote UNIX servers and VIM to edit some files. On just another server I've faced the following issue:

When I used numpad in BASH it worked well, but as soon as I opened VIM my numpad stopped working. All keys caused VIM to insert another symbol on the new line in text. As I saw here, it's a problem of PuTTY configuration. All I needed is just to open terminal settings and select Terminal->Features->Disable application keypad mode. That solved my problem.

Bash: Alt+Alt blocked cursor keys

Alt+. which appends the last argument of the previous command to the current command line is very useful. From the other hand while using this combination it's easy to press Left Alt + Right Alt. In my case it blocked cursor keys. I don't know why, probably I switched some state of the terminal.
Anyway, pressing Left Ctrl + Right Alt returned my terminal to the normal state (found by bruteforcing my keyboard :)).

Sunday, January 17, 2010

VIM: remove highlighting after search

Just found the right way of removing highlighting in VIM after search. Before this I usually just entered another senseless search criteria (which is for sure doesn't exist in the text). What I really liked in the found solution is additional keymapping for such a frequent action.

The command which removes highlighting of the last search is :nohlsearch or it's abbreviation :noh

It can be mapped, for example, to Ctrl-N combination by adding the following line to the .vimrc:
nmap <silent> <C-N> :silent noh<CR>

su: incorrect password

After a long time of stable work of a Linux server (RHEL 5) it suddenly started to refuse logins under regular users. Only root logins were allowed. I guess, it's because of password expiration of my user (the only interactive non-root user in the system) or after some system update which has been done by another adminstrator.

First of all I tried to reset password of my user under root "passwd <user>", but it didn't do the trick. What was strange is that su didn't prompt for password and just returned "su: incorrect password"

There were a lot of reasons of such a problem which were described on a lot of forums. The only solution that helped me has been shown by dballagh in this thread:
pam_tally --user <user> --reset
My user has been blocked by pam_tally module after password expiration or a lot of failed logins.

Friday, January 15, 2010

Segmentation fault has blocked terminal

Yesterday I worked with one of Linux servers and run an application which continually updated my terminal. So it was quite interactive one. Suddenly the application failed (because of internal bug, I'm sure) and blocked my terminal. I mean, I could see output of all programs and Bash prompt, I could type my commands, but I couldn't see "what I type".

I found on one of Russian sites detailed description of the reason of such behavior. In fact, interactive applications which process keyboard input themselves usually modify terminal settings and instruct system to pass keyboard events directly to the application. When they correctly exit, they restore all terminal settings. While in case of "segmentation fault" they do not have time to restore the settings.

Fortunately, there is a simple command that allows to restore terminal state manually:
$ stty sane
This command should be entered blindly, because we can't see our input at the moment. After execution of the command our terminal should return to normal functionality.

There could be another reason of broken terminal: output of binary file. There could be special binary commands which affect behavior of terminal. In this case, one of the following command should help:
$ reset
$ setterm -reset