Entries Tagged 'GNU/Linux' ↓

Shared Libraries

If you have your own shared libraries with the whole set of your favorite functions, probably you will have seen this common error:

./myapp: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or direct

Let’s take a look inside the binary:

tuxedo@host:$> ldd test
        linux-gate.so.1 =>  (0xb7ef6000)
        libatest.so => not found
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7d81000)

By default the system is looking for in the paths defined in the /etc/ld.so.conf, which recursively adds the definitions in the folder /etc/ld.so.conf.d
Here’s the quick trick:

tuxedo@host:$> export LD_LIBRARY_PATH=`pwd`

I use this whereas I’m implementing my library, after that you can put it wherever you feel like.

tuxedo@host:$> ldd test
linux-gate.so.1 =>  (0xb7f5e000)
        libtest.so => /home/tuxedo/syslib/libtest.so (0xb7f56000)
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7de3000)
        /lib/ld-linux.so.2 (0xb7f5f000)

Now the executable will work. I’ll retake this issue, I have some interesting things to tell about shared libraries. Happy coding!!

Xrandr extends your monitor

Long time ago if you wanted to have your laptop and an external monitor working together you had to use Xinerama, lucky me, that has changed. First of all, we need to install xrandr;

 # aptitude install  x11-server-utils

If you executes xrandr, it will show you the outputs you have available:

$ xrandr VGA connected (normal left inverted right)
1280×960 60.0
1280×800 60.0
1152×768 54.8
800×600 56.2
640×480 59.9
LVDS connected 1280×800+0+0 (normal left inverted right) 0mm x 0mm
1280×800 59.9*+ 60.0
1280×768 60.0
1152×768 54.8
1024×768 85.0 75.0 70.1 60.0
832×624 74.6
800×600 85.1 72.2 75.0 60.3 56.2
640×480 85.0 72.8 75.0 59.9
720×400 85.0
640×400 85.1
640×350 85.1

To get all this working, a section must be added into /etc/X11/xorg.conf file

Section “Screen”
Identifier “Default Screen”
Monitor “Configured Monitor”
DefaultDepth 24
SubSection “Display”
Modes “1280×1024″ “1280×800″
Virtual 2560 1024
EndSubSection

EndSection

Using xrandr

Let’s to try out our configuration:

$ xrandr --output VGA --mode 1280x1024 --left-of LVDS

In fact, that is the line we need to put in our little script:

$~ vi .kde/Autostart/dual.sh

Henceforth we can work with an extended desktop, and increase our productivity.

Forwarded ports and RSA key

When I’m doing port forwarding I always get the same annoying message

tuxman@athome:> ssh -p 3000 someuser@localhost

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
22:ce:a2:e1:fe:cc:e6:73:cb:03:96:1e:23:3c:5b:55.
Please contact your system administrator.
Add correct host key in /home/tuxman/.ssh/known_hosts to get rid of this message.
Offending key in /home/tuxman/.ssh/known_hosts:159
RSA host key for [localhost]:4000 has changed and you have requested strict checking.
Host key verification failed.

appending some lines to the ~/.ssh/config file, solves the issue

Host localhost
HostKeyAlias youralias

The HostKeyAlias keyword allows us to define an alias and use it instead of the real name. I frequently use ssh port forwarding and I wanted to get rid of this message.

Background jobs in your bash prompt

In most cases when I’m working with the shell, I send my applications to background, mostly my emacs. Nonetheless I forget quickly, and I open too many times the same file.

Due to my lack of memory I decided to make a function that shows me how many programs I have in background, here is the function:

function get_njobs {
 njobs=$(jobs | wc -l)

 if [ $njobs -gt "0" ];
 then
        echo $njobs |  sed -e 's/\([0-9]*\)/(\1)/g'
 fi
}

function prompt {

#  Shell into Emacs
 if [ $TERM != "dumb" ];
 then
    alias ls='ls --color=auto'
    PS1="${purpple}\u@${close}${YELLOW}\h${close}:{\W}\$(get_njobs)"
 else
        PS1="[\u@\h:\w]"
 fi
}

user@host:{~} emacs &
user@host:{~}(1)

As you may notice, the number inside the brackets remembers me if there is some program running in background. Do not forget to add the function at the end of your bashrc.

SVN switch

Last day I ran into a trouble with my subversion repositories, somebody changed the port I was using, somehow my repositories were not able of finding the original url, and here is the way how sorted it out:

user@host:/myrepo/svn switch –relocate http://mysite.com/myrepo http://mysite.com:7777/myrepo

Now you can do commits.

Troubleshooting Vmware Server 2

This entry will explain two troubles that I found while I was using
Vmware Server 2 :

  1. Initialized monitor device

    If you see an image like shown below,

    you had better check if you have “kvm” modules loaded

    # lsmod | grep kvm
    kvm_intel 31168 0
    kvm 106620 1 kvm_intel

    Now yo have to unload the modules, first “kvm_intel”, if you try to unload kvm you will not be able due to dependency between them.
    At this point it turns out that you can start your virtual machine, but maybe you can not open the virtual console, so let’s go next point.

  2. Remote console plug-in error
  3. If you are trying out to get a console and it shows up a window like this one, you only need to get an earlier version, for me worked out with Firefox 3.5.7. I even tried an upper version, but it did not work out. I guess there are some troubles
    with the last version of Firefox and the plugin.

    That’s all, hopefully it will not take long to solve the problem.

Enable xdmcp in RHEL 5.1

If you want to be able of exporting your X system in another computer, you should keep an eye on this:
vi /etc/gdm/custom.conf

[xdmcp]
Enable=true
[security]
DisallowTCP=true
AllowRemoteRoot=true

After adding up the above lines:

# gdm-restart

Now in your client:

X -query :1

Somehow it can be unsafe to leave available the root access , so I won’t make that decision for you. : )