Find shared objects that depend on a library

Let’s say you’re looking for all binaries that are dynamically linked a shared object and you’d like to find all of them, here’s how you would do it -

find . -name "*.so" | xargs -I '{}' -n 1 sh -c 'ldd_contains=`ldd {} | grep shared_object_dependency`; if [ "$ldd_contains" != "" ] ; then echo {} ; fi'

For example, I’m looking for all shared objects dependent on libdns, you’ll run this -

/usr/lib$ find . -name "*.so*" | xargs -I '{}' -n 1 sh -c 'ldd_contains=`ldd {} | grep libdns`; if [ "$ldd_contains" != "" ] ; then echo {} ; fi'
./libisccfg.so.90
./libbind9.so.90
./libisccfg.so.90.0.6
./libbind9.so.90.0.7

This returned me a bunch of shared objects.

Eclipse crashing on Linux (Ubuntu, Fedora) with GNOME 3

So eclipse is crashing with this weird error?

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fa374d142c1, pid=22733, tid=140342708897536
#
# JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libsoup-2.4.so.1+0x6c2c1]  soup_session_feature_detach+0x11
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/basix/eclipse/hs_err_pid22733.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

The solution is simple. Just add the following line in eclipse.ini -

-Dorg.eclipse.swt.browser.DefaultType=mozilla

Install Jetty 8 in Ubuntu Precise 12.04

On Ubuntu Precise 12.04 (LTS) Linux distribution, the package jetty8 doesn’t exist. It is only available starting with Quantal. Now, like everyone else, I like to roll up my sleeves and get my hands dirty, but this isn’t one of those times. So, I went looking for a way to do this.

Here’s a simple way to do it. Add the following line to your /etc/apt/sources.list:

deb http://archive.ubuntu.com/ubuntu/ quantal universe

Run an apt-get update and install jetty8!

apt-cache showpkg jetty8
Package: jetty8
Versions: 
8.1.3-4 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_universe_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_universe_binary-amd64_Packages
                  MD5: 6145995b8766cbb4600d50bf0658018e
 Description Language: en
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_universe_i18n_Translation-en
                  MD5: 6145995b8766cbb4600d50bf0658018e


Reverse Depends: 
  libjetty8-java,jetty8
  libjetty8-extra-java,jetty8
Dependencies: 
8.1.3-4 - libjetty8-java (2 8.1.3-4) adduser (0 (null)) apache2-utils (0 (null)) default-jre-headless (16 (null)) java5-runtime-headless (16 (null)) java6-runtime-headless (0 (null)) libjetty8-extra-java (2 8.1.3-4) libjetty8-java-doc (2 8.1.3-4) 
Provides: 
8.1.3-4 - 
Reverse Provides: 

Forgot your mysql root password? Here’s how you can easily reset it.

You need to have root access to the machine that is running the mysql daemon. This is the UNIX root account (if you don’t understand what I’m talking about, you should probably first learn about it.)

Create a file called: /tmp/mysql-reset-pwd with the following contents:

UPDATE mysql.user SET Password=PASSWORD('MyNewPassword') WHERE User='root';
FLUSH PRIVILEGES;

Replace ‘MyNewPassword’ with whatever you want your new password to be.

Next – run this command:

$ sudo chown mysql:mysql /tmp/mysql-reset-pwd
$ sudo /etc/init.d/mysql stop
$ sudo mysqld_safe --init-file=/tmp/mysql-reset-pwd --log-error=/tmp/error.log --skip-syslog

Now mysql should come up with your root password reset to ‘MyNewPassword’. Give it a whirl!

Tip of the day: Count the number of CPU cores on your Linux machine

Simply consult the proc file system. Here’s how –

$ cat /proc/cpuinfo

That is a special file which has all information pertaining to your system’s CPU information. Sample output looks like –

processor	: 0
model name	: Intel(R) Xeon(TM) CPU 3.60GHz
cache size	: 1024 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 1
processor	: 1
model name	: Intel(R) Xeon(TM) CPU 3.60GHz
cache size	: 1024 KB
physical id	: 3
siblings	: 2
core id		: 0
cpu cores	: 1
processor	: 2
model name	: Intel(R) Xeon(TM) CPU 3.60GHz
cache size	: 1024 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 1
processor	: 3
model name	: Intel(R) Xeon(TM) CPU 3.60GHz
cache size	: 1024 KB
physical id	: 3
siblings	: 2
core id		: 0
cpu cores	: 1

Please note there are a lot of other fields.

Tip of the day: Reset your root password without the old password

Disclaimer: This method would work only for unencrypted file systems and mostly on Redhat/Fedora machines.

First, reboot your machine.

$ shutdown -r now

Second, When the grub menu shows up, press ‘e’. This should put you in an ‘edit’ mode. Scroll down to the option which says ‘kernel’ and scroll to the very end.

Lastly, simply append ’1′ to the end of the line and ensure that there is a space between the last character and the 1 that you added.

Press enter and ‘b’ to boot. At this point the system should put you in a single user mode as user root. Here you can simply issue ‘passwd’ command and change the root password and reboot into multi-user mode.