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 :)

Thursday, December 9, 2010

Windows 7: Arrows on shortcuts

There are 2 problems in one:

  • Big ugly arrows on shortcuts in Windows 7
  • Appending of "Link for" to all newly created shortcuts
Both of them are solved by simply correcting 2 values in Windows registry and adding a new file to a system.

New file is a blank icon (which probably can be created manualy, but I've downloaded it from here). This file, called for example blank.ico, should be put into %systemroot%. Now let's tweak the registry.

To disable arrows, create a key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell Icons] and add parameter with RG_EXPAND_SZ type:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell Icons]

To disable "link for", set:

I tested it on my Windows 7. I'm not sure, but probably this solution also applies for other versions of Windows.

Friday, September 3, 2010

Man: specify the page to browse

It's just a small notice which can be found in man help. The reason I wrote this post is that it was not evident for me and I spent some time to pick this information from man man.

So, the task is to open a particular man page instead of default one. It can be found in man man:
-S section_list
List is a colon separated list of manual sections to search. This option overrides the MANSECT environment variable.

I used to say "man page" speaking about page numbers, but they call it sections. So, to open the 3rd page for syslog:
man -S syslog
By default, it usually opens syslog(2)

Wednesday, June 2, 2010

Linux: add custom script to chkconfig

One of my servers runs Red Hat EL5 and thus there's chkconfig available to configure services for different run levels. I developed a script for my application (runs as daemon) which I put into /etc/init.d/my_app. This script has the same CLI as all other scripts which control services. I mean it accepts one argument that can be "start", "stop", "restart" and "status" (I know, there could be other options, but this set was enough for me).

Then I decided not to create symbolic links in /etc/rc* manually, but to use chkconfig instead and received the following:
# chkconfig --add my_app
service file does not support chkconfig

The reason is that chkconfig has some requirements for comments in the begining of the script. They should be something like this:
# chkconfig: 2345 95 20
# description: This application was developed by me and is tested on this server
# processname: my_app

chkconfig line tells chkconfig that application should run on 2, 3, 4 and 5 run levels and activation and deactivation priorities. The greater the number, the less priority has your application (see numbers in /etc/rc*.d/ links names)

After these lines are inserted into your script, service should be added to chkconfig without any problems.

Sunday, March 28, 2010

Windows: Welcome screen default keyboard layout

I use Windows 7 as primary OS, but I faced the same problem in previous versions of Windows too. The problem is that I use russian version of this system and it doesn't allow to select default keyboard layout and toggle keys during system installation. So, each time I boot my system I have to change language with Alt-Shift keys (I used to press Ctrl-Shift). It's very inconvinient!

The solution is here. One should change the following registry keys, which control default keyboard layout and toggle keys:
HKEY_USERS\.DEFAULT\Keyboard Layout\Preload\1;
HKEY_USERS\.DEFAULT\Keyboard Layout\Preload\2;

These 2 parameters control the primary (key 1), default language and other languages (keys 2, 3, etc.). The values of these keys contain language id. English layout is '00000409'. Russian is '00000419'. ID's for other languages could be found in HKEY_CURRENT_USER/Keyboard layout/Preload if the required language is configured for current user.

So, in my case parameter set was:
HKEY_USERS\.DEFAULT\Keyboard Layout\Preload\1 REG_SZ 00000409
HKEY_USERS\.DEFAULT\Keyboard Layout\Preload\2 REG_SZ 00000419

Layout switching keys are controlled by HKEY_USERS\.DEFAULT\Keyboard Layout\Toggle\Hotkey key. Value '1' means Alt-Shift, value '2' means Ctrl-Shift.

The following script changes default login layout to English and toggle keys to Ctrl-Shift:
reg add "HKU\.DEFAULT\Keyboard Layout\Preload" /v 1 /t REG_SZ /d 00000409 /f
reg add "HKU\.DEFAULT\Keyboard Layout\Preload" /v 2 /t REG_SZ /d 00000419 /f
reg add "HKU\.DEFAULT\Keyboard Layout\Toggle" /v Hotkey /t REG_SZ /d 2 /f

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