..bits & bytes teleported

Tuesday Oct 14, 2008

Just upgraded to Ubuntu 8.10 Beta. Its simple to do - if you are running Ubuntu 8.04:
  • Alt + F2
  • 'update-manager -d'
 


                      




On Restart, you will have new entries in the GRUB menu- an extra entry will be added for the new kernel.

Wednesday Aug 20, 2008

According to its man page-'apt-rdepends - performs recursive dependency listings similar to apt-cache'. For a similar use of apt-cache, see my earlier blog post: http://blogs.sun.com/amitsaha/entry/debian_package_dependencies_apt_cache

Let us now see 'apt-rdepends' in action:

Finding the dependencies of 'mysql-server' package:

amit@ubuntu804-book:~$ apt-rdepends mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-server
  Depends: mysql-server-5.0
mysql-server-5.0
  Depends: debconf (>= 0.5)
  Depends: debconf-2.0
  Depends: libc6 (>= 2.7-1)
  Depends: libdbi-perl
  Depends: libgcc1 (>= 1:4.1.1-21)
  Depends: libmysqlclient15off (>= 5.0.27-1)
  Depends: libncurses5 (>= 5.6+20071006-3)
  Depends: libreadline5 (>= 5.2)
  Depends: libstdc++6 (>= 4.1.1-21)
  Depends: libwrap0
  Depends: lsb-base (>= 3.0-10)
  Depends: mysql-client-5.0 (>= 5.0.51a-3ubuntu5)
  Depends: passwd
  Depends: perl (>= 5.6)
  Depends: psmisc
  Depends: zlib1g (>= 1:1.2.3.3.dfsg-1)
  PreDepends: adduser (>= 3.40)
  PreDepends: debconf
  PreDepends: mysql-common (>= 5.0.51a-3ubuntu5)
debconf
  Depends: debconf-english
  Depends: debconf-i18n
  PreDepends: perl-base (>= 5.6.1-4)
debconf-english
  Depends: debconf
debconf-i18n
  Depends: debconf
  Depends: liblocale-gettext-perl
  Depends: libtext-charwidth-perl
  Depends: libtext-iconv-perl
  Depends: libtext-wrapi18n-perl
liblocale-gettext-perl
  Depends: libc6 (>= 2.2)
  Depends: perl-base (>= 5.8.8-6)
  Depends: perlapi-5.8.8
libc6
  Depends: libgcc1
libgcc1
  Depends: gcc-4.2-base (= 4.2.3-2ubuntu7)
  Depends: libc6 (>= 2.7-1)
gcc-4.2-base
perl-base
  PreDepends: libc6 (>= 2.6.1-1)
perlapi-5.8.8
libtext-charwidth-perl
  Depends: libc6 (>= 2.5-0ubuntu1)
  Depends: perl-base (>= 5.8.8-7)
  Depends: perlapi-5.8.8
libtext-iconv-perl
  Depends: libc6 (>= 2.4-1)
  Depends: perl-base (>= 5.8.7-10ubuntu2)
  Depends: perlapi-5.8.7
perlapi-5.8.7
libtext-wrapi18n-perl
  Depends: libtext-charwidth-perl
debconf-2.0
libdbi-perl
  Depends: libc6 (>= 2.6.1-1)
  Depends: libplrpc-perl
  Depends: perl (>= 5.8.4-5)
  Depends: perl-modules
  Depends: perlapi-5.8.4
libplrpc-perl
  Depends: libnet-daemon-perl
  Depends: libstorable-perl
  Depends: perl (>= 5.6.0-16)
  Depends: perl-modules (>= 5.8.0-10)
libnet-daemon-perl
  Depends: perl (>= 5.6.0-16)
perl
  Depends: libc6 (>= 2.6.1-1)
  Depends: libdb4.6
  Depends: libgdbm3
  Depends: perl-base (= 5.8.8-12)
  Depends: perl-modules (>= 5.8.8-12)
libdb4.6
  Depends: libc6 (>= 2.7-1)
libgdbm3
  Depends: libc6 (>= 2.4-1)
perl-modules
  Depends: perl (>= 5.8.8-8)
libstorable-perl
perlapi-5.8.4
libmysqlclient15off
  Depends: libc6 (>= 2.7-1)
  Depends: mysql-common (>= 5.0.51a-3ubuntu5)
  Depends: zlib1g (>= 1:1.2.3.3.dfsg-1)
mysql-common
zlib1g
  Depends: libc6 (>= 2.6.1-1)
libncurses5
  Depends: libc6 (>= 2.7-1)
libreadline5
  Depends: libc6 (>= 2.6-1)
  Depends: libncurses5 (>= 5.6)
  Depends: readline-common
readline-common
libstdc++6
  Depends: gcc-4.2-base (= 4.2.3-2ubuntu7)
  Depends: libc6 (>= 2.7-1)
  Depends: libgcc1 (>= 1:4.1.1-21)
libwrap0
  Depends: libc6 (>= 2.6)
lsb-base
  Depends: libncurses5
  Depends: libpam0g
  Depends: ncurses-bin
  Depends: sed
libpam0g
  Depends: debconf (>= 0.5)
  Depends: debconf-2.0
  Depends: libc6 (>= 2.4)
  Depends: libpam-runtime
libpam-runtime
ncurses-bin
  PreDepends: libc6 (>= 2.7-1)
  PreDepends: libncurses5 (>= 5.6+20071006-3)
sed
  PreDepends: libc6 (>= 2.6.1-1)
mysql-client-5.0
  Depends: debianutils (>= 1.6)
  Depends: libc6 (>= 2.7-1)
  Depends: libdbd-mysql-perl (>= 1.2202)
  Depends: libdbi-perl
  Depends: libgcc1 (>= 1:4.1.1-21)
  Depends: libmysqlclient15off (>= 5.0.51a-3ubuntu5)
  Depends: libncurses5 (>= 5.6+20071006-3)
  Depends: libreadline5 (>= 5.2)
  Depends: libstdc++6 (>= 4.1.1-21)
  Depends: libwrap0
  Depends: mysql-common (>= 5.0.51a-3ubuntu5)
  Depends: perl (>= 5.6.0-16)
  Depends: zlib1g (>= 1:1.2.3.3.dfsg-1)
debianutils
  PreDepends: coreutils (>= 4.5.8-1)
  PreDepends: libc6 (>= 2.7-1)
  PreDepends: mktemp
coreutils
  PreDepends: libacl1 (>= 2.2.11-1)
  PreDepends: libc6 (>= 2.7-1)
  PreDepends: libselinux1
libacl1
  Depends: libattr1 (>= 2.4.4-1)
  Depends: libc6 (>= 2.6.1-1)
libattr1
  Depends: libc6 (>= 2.6.1-1)
libselinux1
  Depends: libc6 (>= 2.7-1)
mktemp
  PreDepends: libc6 (>= 2.7-1)
libdbd-mysql-perl
  Depends: libc6 (>= 2.6.1-1)
  Depends: libdbi-perl (>= 1.08-1)
  Depends: libmysqlclient15off (>= 5.0.27-1)
  Depends: perl (>= 5.8.8-7ubuntu3)
  Depends: perlapi-5.8.8
passwd
  Depends: debianutils (>= 2.15.2)
  Depends: libc6 (>= 2.7-1)
  Depends: libpam-modules (>= 0.72-5)
  Depends: libpam0g (>= 0.99.7.1)
  Depends: libselinux1
  Depends: login (>= 970502-1)
libpam-modules
  Depends: libc6 (>= 2.4)
  Depends: libdb4.6
  Depends: libpam0g (>= 0.99.7.1)
  Depends: libselinux1
login
  Depends: libpam-modules (>= 0.72-5)
  PreDepends: libc6 (>= 2.7-1)
  PreDepends: libpam-runtime (>= 0.76-14)
  PreDepends: libpam0g (>= 0.99.7.1)
psmisc
  Depends: libc6 (>= 2.6.1-1)
  Depends: libncurses5 (>= 5.6)
adduser
  Depends: debconf
  Depends: debconf-2.0
  Depends: passwd (>= 1:4.0.12)
  Depends: perl-base (>= 5.6.0)

As you can see above, there is a recursive dependency listing of the packages.

Let us now try to plot a dependency graph using 'apt-rdepends'. We shall make use of the '--vcg' switch which takes a list of packages on the command line and generates output suitable for use by xvcg. The result will be a set of nodes and edges representing the relationships between the packages.

amit@ubuntu804-book:~$ apt-rdepends --xvcg mysql-server > mysql-server-xvcg
amit@ubuntu804-book:~$ xvcg mysql-server-xvcg

What you have is a graphical representation of the dependency of the package:

Something to note from the man page of 'apt-rdepends' however is -'apt-rdepends exists. This functionality should really reside in apt-cache itself.'

Tuesday Aug 19, 2008

Anil Gulecha's post: Viewing dependencies graphically on apt based systems is nice stuff.

It demonstrates the use of 'apt-cache' to generate graphical visualizations of package dependencies using 'graphviz'.

However, as 'apt-rdepends' man page says: Caution, dotty cannot graph larger sets of packages and I found it to be so when I tried to obtain a package dependency graph for firefox-3.0


Wednesday Jul 30, 2008

Stumbled upon this link at http://www.fsckin.com/2008/07/27/the-most-interesting-readme-file-ever/ which points me to the README file of gnome-cups-manager:

Once upon a time there was a printer who lived in the woods. He was a lonely printer, because nobody knew how to configure him. He hoped and hoped for someone to play with.

One day, the wind passed by the printer’s cottage. “Whoosh,” said the wind. The printer became excited. Maybe the wind would be his friend!

“Will you be my friend?” the printer asked.

“Whoosh,” said the wind.

“What does that mean?” asked the printer.

“Whoosh,” said the wind, and with that it was gone.

The printer was confused. He spent the rest of the day thinking and jamming paper (for that is what little printers do when they are confused).

The next day a storm came. The rain came pouring down, darkening the morning sky and destroying the printer’s garden. The little printer was upset. “Why are you being so mean to me?” he asked.

“Pitter Patter, Pitter Patter,” said the rain.

“Will you be my friend?” the printer asked shyly.

“Pitter Patter, Pitter Patter,” said the rain, and then it left and the sun came out.

The printer was sad. He spent the rest of the day inside, sobbing and blinking lights cryptically (for that is what little printers do when they are sad).

Then one day, a little girl stumbled into the printer’s clearing in the woods. The printer looked at this curious sight. He didn’t know what to think.

The little girl looked up at him. “Will you be my friend?” she asked.

“Yes,” said the printer.

“What is your name?” asked the little girl.

“HP 4100TN”, replied the printer.

“My name is gnome-cups-manager” said the little girl.

The printer was happy. He spent the rest of the day playing games and printing documents, for that is what little printers do when they are happy.

Verify it yourself by d/l-ing a tarball from here

Tuesday Jul 22, 2008

 _____________________________________________________________
/ Your mind is the part of you that says,                     \
|         "Why'n'tcha eat that piece of cake?"                |
| ... and then, twenty minutes later, says,                   |
|         "Y'know, if I were you, I wouldn't have done that!" |
|                 -- Steven and Ondrea Levine                 |
|                                                             |
\ [fortune] http://iheartquotes.com/fortune/show/46671        /
 -------------------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
Just append these lines to your '.bashrc' and everytime you login, you will be greeted with a cow (cowsay) blurting out a random quote from  http://www.iheartquotes.com/
# Pull quotes from the API
# Source: http://www.iheartquotes.com/api

alias getfortune='wget --timeout=3 -O - -q'
alias fortune='getfortune http://www.iheartquotes.com/api/v1/random'
alias myfortune='getfortune http://www.iheartquotes.com/api/v1/random?source=joel_on_software+paul_graham+prog_style'
fortune | cowsay -n

You may also enjoy this: http://ubuntuforums.org/archive/index.php/t-39572.html

Wednesday Jul 16, 2008

Shells cache the commands which you have executed so as to save the time required to search your PATH every time you execute it. Type 'hash' in your terminal and you will see something like:
$ hash

hits    command
  1    /usr/bin/which
  2    /usr/local/bin/log4cpp-config
  1    /usr/bin/gnome-screensaver
  1    /sbin/ldconfig 

which is the list of commands I have so far executed in this instance of the terminal, which is verified by:

$ type ldconfig
ldconfig is hashed (/sbin/ldconfig)

Every time you execute a (non shell-builtin) command, it is automatically added to the 'cache' and lives there for the rest of the session- once you logout or even close the pseudo-terminal (like gnome-terminal) it is gone.

Another observation, the most recently executed command is added to the bottom of the list. I found this a good read: http://crashingdaily.wordpress.com/2008/04/21/hashing-the-executables-a-look-at-hash-and-type/

I am using Ubuntu Linux 8.04 and using log4cpp 1.0

Installing log4cpp from sources

  • D/l the sources are available from Sourceforge download page
  • ./configure
  • make
  • make check
  • sudo make install

You may also install log4cpp from repository using 'apt-get'.

Checking the installation

The log4cpp source tarball contains simple examples using the API in the 'tests/' sub-directory. Let us try one of them (testConfig.cpp) to check the installation:

  $ g++ -o testConfig testConfig.cpp -lpthread -llog4cpp
'lpthread' is required to link the pthreads shared libraries and 'log4cpp' is the log4cpp shared library. Execute it:
$./testConfig
I got this error:
./testConfig: error while loading shared libraries: liblog4cpp.so.4: cannot open shared object file: No such file or directory
I had the shared lib file in the '/usr/local/lib' directory. Still, I got the error. May be I needed a ld cache updation. ⁞So I just ran the 'ldconfig' to update the 'ld.so.cache' and then executed the object file:
$ ./testConfig 
1216198972 ERROR  : root error
1216198972 WARN  : root warn
1216198972 ERROR sub1 : sub1 error
1216198972 WARN sub1 : sub1 warn
The message sub2 error at time 2008-07-16 14:32:55,024
1216198975 ERROR sub1.sub2 : sub2 error
1216198975 ERROR  : root error
1216198975 WARN  : root warn
1216198975 ERROR sub1 : sub1 error
1216198975 WARN sub1 : sub1 warn
The message sub2 error at time 2008-07-16 14:32:58,374
1216198978 ERROR sub1.sub2 : sub2 error
The message test vform 123 at time 2008-07-16 14:32:58,375
1216198978 ERROR sub1.sub2 : test vform 123

Thus, log4cpp is ready to be used in your applications.

log4cpp-config

log4cpp-config is a command line tool which is also installed when you do a 'make install'. You can use it to obtain various information about your log4cpp installation.

$ log4cpp-config --help
All available options:
  --prefix=DIR and   change $prefix and $exec-prefix
  --exec-prefix=DIR  (affects all other options)
  --prefix           $prefix        /usr/local
  --exec_prefix  or... 
  --eprefix          $exec_prefix   /usr/local
  --version          $version        1.0
  --cflags           -I$includedir  unless it is /usr/include
  --libs             -L$libdir $LIBS  -llog4cpp  -lnsl 
  --package          $package       log4cpp
  --bindir           $bindir        /usr/local/bin
  --sbindir          $sbindir       /usr/local/sbin
  --libexecdir       $libexecdir    /usr/local/libexec
  --datadir          $datadir       /usr/local/share
  --sysconfdir       $sysconfdir    /usr/local/etc
  --sharedstatedir   $sharedstatedir/usr/local/com
  --localstatedir    $localstatedir /usr/local/var
  --libdir           $libdir        /usr/local/lib
  --infodir          $infodir       /usr/local/share/info
  --mandir           $mandir        /usr/local/share/man
  --target           $target        
  --host             $host          i686-pc-linux-gnu
  --build            $build         i686-pc-linux-gnu
  --pkgdatadir       $datadir/$package    /usr/local/share/log4cpp
  --pkglibdir        $libdir/$package     /usr/local/lib/log4cpp
  --pkgincludedir    $includedir/$package /usr/local/include/log4cpp
  --template-version $template_version     1.0.0
  --help

I am yet to find other uses of it. Seems like that you can change the various defaults using this tool.

Thursday Jul 10, 2008

You can obtain ACPI (Advanced Configuration & Power Interface) information on your Linux notebook using a utility by the same name- 'acpi'.

 Here are some demos:

  1. $ acpi
         Battery 1: charged, 100%
    
  2. $ acpi -a
         Battery 1: charged, 100%
      AC Adapter 1: on-line
    
  3. $ acpi -t
         Battery 1: charged, 100%
         Thermal 1: ok, 54.0 degrees C
    
  4. r$ acpi -V
         Battery 1: charged, 100%
         Thermal 1: ok, 54.0 degrees C
      AC Adapter 1: on-line
    
'acpi' utility obtains the information from the files in the '/proc/acpi' directory which contain sub-directories and files containing all information related to temperature, etc.
dr-xr-xr-x 3 root root 0 2008-07-10 20:26 ac_adapter
dr-xr-xr-x 2 root root 0 2008-07-10 20:26 acer
-rw-r--r-- 1 root root 0 2008-07-10 20:26 alarm
dr-xr-xr-x 3 root root 0 2008-07-10 20:26 battery
dr-xr-xr-x 5 root root 0 2008-07-10 20:26 button
-r-------- 1 root root 0 2008-07-10 20:26 dsdt
dr-xr-xr-x 3 root root 0 2008-07-10 20:26 embedded_controller
-r-------- 1 root root 0 2008-07-10 19:50 event
-r-------- 1 root root 0 2008-07-10 20:26 fadt
dr-xr-xr-x 2 root root 0 2008-07-10 20:26 fan
-r--r--r-- 1 root root 0 2008-07-10 20:26 info
dr-xr-xr-x 2 root root 0 2008-07-10 20:26 power_resource
dr-xr-xr-x 3 root root 0 2008-07-10 20:26 processor
-rw-r--r-- 1 root root 0 2008-07-10 20:26 sleep
dr-xr-xr-x 3 root root 0 2008-07-10 20:26 thermal_zone
dr-xr-xr-x 3 root root 0 2008-07-10 20:26 video
-rw-r--r-- 1 root root 0 2008-07-10 20:26 wakeup

http://www.lesswatts.org/projects/index.php is currently working on the Linux ACPI project

Monday Jun 30, 2008

I got a new Maxtor OneTouch 4 Mini 160 GB USB HDD.

Like many other computer peripherals, accessories this was labeled to be compatible with Windows and Macintosh, as well (Wow!!). So, what does a Linux guy do? *Evil Grin*.

Simple, I plug it in.

The light on the HDD starts blinking and I see the following error dialog: (Wow, almost perfect)


As the messages show, the HDD is pre-formatted with NTFS. Now there are two ways out:

  1. Either you can use the 'mount' command using the switches, flags as suggested above (it works fine).
  2. You can go ahead and format your HDD. For eg. mkfs.ext3 /dev/sdb1 will create a ext3 partition on the HDD

After doing any of the above steps, you can use your HDD just like any other storage device.

Perhaps even the HDD manufacturer knows that their product will work invariably on Linux and hence they do not mention it. :-)