Thursday, January 31, 2013

apt-get remove vs. purge vs. autoremove

Let's explain this by taking Tomboy package as the one to be removed.

remove
apt-get remove tomboy
This removes the tomboy package, but it's configuration files and installed dependencies will remain in the system.

purge
apt-get purge tomboy
This removes the package as well as its configuration files. But the dependencies will remain in the system. However, configuration files in the home directory won't get removed.
This command is same as using --purge option with the above remove command.

autoremove
apt-get autoremove tomboy
This will remove the package as well as its dependencies, if those dependencies aren't used by other packages.
If the package name is not specified with autoremove, it will remove all the unused dependencies in the system.

Ref:
[1] https://help.ubuntu.com/community/AptGet/Howto
[2] http://askubuntu.com/questions/187888/what-is-the-correct-way-to-completely-remove-an-application

Wednesday, January 23, 2013

How to install Subversion 1.7.8 in Ubuntu 12.10

Quantal (Ubuntu 12.10) repositories contain SVN 1.7.5. You can update to latest SVN (ver. 1.7.8) using a shell script provided by WANdisco [1].

To install this there is a dependency to be resolved - libdb4.8 package, which is not available in Quantal repos. So we need to get it from the Precise (Ubuntu 12.04) repo.

We can either...

1) download the .deb from [2] and install,
2) or rename "quantal" in /etc/apt/sources.list with "precise" and run an apt-get update.

I did #2 (which is probably the long route to do this) because it will resolve any other dependency script might have, which is intended for Precise. Otherwise we have to download the .debs of those dependencies as well.

Finally, run the script downloaded from WANdisco. Done! :)

 Ref:
[1] http://www.wandisco.com/subversion/download#ubuntu_precise
[2] http://www.ubuntuupdates.org/package/core/precise/main/base/libdb4.8

Monday, January 21, 2013

How to check the number of CPU cores in Linux

Use the lscpu command.

Following are the details of my Intel® Core™ i7-3520M.


The main advantage of this command is to determine the actual number of 'cores' in the processor. In a multi-threading processor this is lesser than the number of CPUs.

Friday, January 18, 2013

SAML Subject confirmation methods: Bearer vs. Holder of Key vs. Sender Vouches

Subject confirmation methods are how a relying party (RP), in other words the end service, can make sure a particular security token issued by a Security Token Service (STS), is brought by the legitimate subject.

If this is not done, a 3rd party can take the token from the wire and send any request it wants including that token. RP will trust that illegitimate party.

Following discuss these three methods.

The common aspect is, obviously, RP should always trust the STS.

Bearer
This is actually not a confirmation method - means subject confirmation is not needed! The RP simply trusts whoever brings the token!

Holder of Key (HoK)
1. STS includes the public key of the client, inside the security token and signs it.
2. Then before sending, client itself signs the request.
3. When the RP receives it, it first validates STS signature and then validates client's signature with the public key embedded inside the token.

Sender Vouches
1. Rather than authenticating with the STS, here, Client authenticates with an intermediate service.
2. The intermediary gets the security token from the STS.
3. Then it signs the request and sends to the RP.
4. RP trusts both the intermediary and the STS. So, it validates both of them.

Ref:
SAML subject confirmation methods: holder-of-key vs. sender-vouches

Monday, January 14, 2013

How to set Terminator as the default terminal emulator

Running following commands will change the default terminal emulator to Terminator [1].
gsettings set org.gnome.desktop.default-applications.terminal exec /usr/bin/terminator
gsettings set org.gnome.desktop.default-applications.terminal exec-arg "-x"
This can be easily done from dconf Editor as well.


After doing this, Ctrl+Alt+T and as well as "Open in Terminal" Nautilus script will open the Terminator rather than the normal Terminal.

Ref: [1] http://askubuntu.com/questions/76712/setting-nautilus-open-terminal-to-launch-terminator-rather-than-gnome-terminal

How to install JD-GUI on Ubuntu 64 bit

JD-GUI is the best Java decompiler around.

However, it requires 32bit gtk libraries. Otherwise it gives the error: "error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory"

So, to run it on a 64bit Ubuntu we can install the ia32-libs-gtk package [1].
apt-get install ia32-libs-gtk
We can further add it to the Nautilus 'open with' pop-up and then make it the default app to open .class files. Adding an app to that pop-up is explained here[2].

After that is done, we can open any .class file from JD-GUI; even within jar files.

Ref:
[1] http://lunduke.com/forum/discussion/126/ubuntu-12-04-64bit-error-while-loading-shared-libraries-libgtk-x11-2-0-so-0/p1
[2] http://dulanja.blogspot.com/2013/01/how-to-add-program-to-nautilus-open.html

Sunday, January 13, 2013

How to resolve dependency errors when installed by dpkg

It seems 'dpkg' cannot resolve the dependencies of a .deb. If a dependency error occurs during an installation, we can resolve it by using apt-get as following.
sudo apt-get -f install
 -f is equal to specifying --fix-broken

Ref: [1] http://askubuntu.com/questions/222090/cannot-install-skype-due-to-dependency-errors-spkg-doesnt-install-dependencies

How to save backlight settings in Ubuntu

In Ubuntu 12.10 (and many other versions) back-light setting changes we do are not retained after a restart or a resume; back-light is always set to maximum, which is very irritating.

To save the backlight to a specific value we can use xbacklight.

We can specify a percentage (I prefer 73%) as following:
xbacklight -set 73
We have to add this as a 'Startup Application' in order to apply the brightness change at the Ubuntu login.

How to install Oracle JDK in Ubuntu 64bit

1) Download the JDK from oracle.
2) Extract and move it to /usr/lib/jvm
3) Update alternatives as following:
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_37/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_37/bin/javac" 1
$ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_37/jre/lib/amd64/libnpjp2.so" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_37/bin/javaws" 1
4) Choose defaults out of alternatives as following:
 $ sudo update-alternatives --config java
 $ sudo update-alternatives --config javac
 $ sudo update-alternatives --config mozilla-javaplugin.so
 $ sudo update-alternatives --config javaws
5) Set up JAVA_HOME and PATH environment variables in ~/.bashrc :
export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_37
export PATH=$JAVA_HOME/bin:$PATH
6) Reload bash configuration:
dulanja@dulanja-t530:~$ su - dulanja
Password:
Done!

Ref:
[1] https://help.ubuntu.com/community/Java
[2] http://www.ubuntututorials.com/install-oracle-java-jdk-7-ubuntu-12-04/

Wednesday, January 9, 2013

How to add a program to Nautilus' 'open with' menu

Nautilus has a limited set of applications which it displays in the "open with" popup. Following should be done to add an application to that list.

In that specific application's .desktop file located in /usr/share/applications, %f flag should be inserted at the end of the executable line (starting with "Exec=").

e.g. /usr/share/applications/jd-gui.desktop
[Desktop Entry]
Encoding=UTF-8
Name=JD-GUI
Comment=JD-GUI Java Decompiler
Exec=/home/dulanja/work/dev/tools/jd-gui/jd-gui %f
Icon=/home/dulanja/work/dev/tools/jd-gui/jd-gui.png
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true


Ref:
[1]http://ubuntugenius.wordpress.com/2012/06/18/ubuntu-fix-add-program-to-list-of-applications-in-open-with-when-right-clicking-files-in-nautilus/

Monday, January 7, 2013

How to find a string inside a specific file type in Linux

Use find and grep commands combined as following example.
find . -name 'pom.xml' | xargs grep -i "org.wso2.carbon.sts 
xargsgives the result of find as the input to grep.
Ref:
[1] http://insanelabs.com/linux/linux-find-a-string-recursively-within-files/

Friday, January 4, 2013

How to check the loaded bundles in an OSGi container

Server with the OSGi container should be run with the option -DosgiConsole.
e.g.
$ ./wso2server.sh -DosgiConsole
After the startup we can issue the following command.
osgi> ss
This will display all the bundles loaded in to the OSGi container. We can filter the results by specifying a string.
e.g.
osgi> ss sts

Framework is launched.

id    State       Bundle
187    ACTIVE      org.wso2.carbon.identity.sts.mgt_4.0.3
188    ACTIVE      org.wso2.carbon.identity.sts.mgt.stub_4.0.0
189    ACTIVE      org.wso2.carbon.identity.sts.mgt.ui_4.0.3
190    ACTIVE      org.wso2.carbon.identity.sts.passive_4.0.3
191    ACTIVE      org.wso2.carbon.identity.sts.passive.stub_4.0.0
192    ACTIVE      org.wso2.carbon.identity.sts.passive.ui_4.0.3
193    ACTIVE      org.wso2.carbon.identity.sts.store_4.0.3
264    ACTIVE      org.wso2.carbon.sts_4.0.5
265    ACTIVE      org.wso2.carbon.sts.stub_4.0.0
266    ACTIVE      org.wso2.carbon.sts.ui_4.0.1