Search

Determine are you running on battery through command prompt


If you are running in the text mode and want to find out if your laptop is running on battery or on ac power you can use the command "on_ac_power".
The command returns "0" if laptop is running on ac power, 1 if it is runnning on battery and 255 if it can not determine.
For eg:

$ ac_on_power
$ echo $? 
0

Thus the laptop is running on ac power.
You can use the following script to make the output look more user friendly.

#!/bin/bash 


on_ac_power
if  [  $? -eq 0  ]
 then 
echo "Running on ac power"
elif  [  $? -eq 1  ]
  then 
echo "Running on Battery"
else 
echo "Can not detemine" 
fi 


Save the script as power.sh and run it as follows.

$ sh power.sh 
Running on ac power


Thus giving the required information in more readable format.


PangoRendererClass' has no member named 'draw_glyph_item' : update tango

PangoRendererClass' has no member named 'draw_glyph_item' 

Hit the above error while compiling gtk+ version 3.0.

The problem was with the pango version, got the error when pango version was 1.20.
But the error did not appear after updating pango to 1.28. 

usr/include/X11/extensions/XTest.h:50:35: X11/extensions/XInput.h: No such file or directory


usr/include/X11/extensions/XTest.h:50:35: X11/extensions/XInput.h: No such file or directory

Hit The above error while compiling gtk+ 3.0 version , the workaround is to install libxi-dev package.

$ sudo apt-get install libxi-dev 


All fonts in gnome turn into square symbols

This is a problem encountered while installing gtk+. After installing all of the packages required to install gtk+ and a system reboot all the characters in filenames, menu etc had turned into just square symbols. None of the fonts were visible.
The culprit was the package "pango" which is required for gtk+.  To get back the usual display it was required to unistall pango which can be done from the same folder from which it was installed from source.

cd to the folder that has source of pango

$ sudo make uninstall
$sudo reboot

After reboot all the fonts were back :-)
configure: error:
*** Checks for TIFF loader failed. You can build without it by passing
*** --without-libtiff to configure but some programs using GTK+ may
*** not work properly


If you hit the above error while configuring gdk-pixbuf or any other package while installing gtk+, the workaround is
to install libtiff4-dev

$ sudo apt-get install libtiff4-dev  

Error while configuring Gdk-pixbuf for gtk


The following error might appear while configuring Gdk-pixbuf  which is needed for installing Gtk.

checking for GLIB - version >= 2.25.15...
*** 'pkg-config --modversion glib-2.0' returned 2.29.12, but GLIB (2.24.2)
*** was found! If pkg-config was correct, then it is best
*** to remove the old version of GLib. You may also be able to fix the error
*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
*** /etc/ld.so.conf. Make sure you have run ldconfig if that is
*** required on your system.
*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH
*** to point to the correct configuration files
no
configure: error:
*** GLIB 2.25.15 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/pub/gtk/



The error could be because of multiple versions of glib versions present in your system.

Workaround:

Look at the contents of "/lib"

$ ls -l libg*
-rw-r--r-- 1 root root  116600 Nov 14  2010 libgcc_s.so.1
lrwxrwxrwx 1 root root      23 Jul 11 14:00 libglib-2.0.so.0 -> libglib-2.0.so.0.2400.2
lrwxrwxrwx 1 root root      23 Jul 11 14:00 libglib-2.0.so.0.2400.2


If the output is some thing similar to the above ,we can see that the lib file present in the /lib is of 2.24 version which is being detected while configuring. To change this we need to locate the newer ".so" file.


Run the following commands to locate if a newer file is present.

$sudo updatedb 
$sudo locate libglib-2.so.0

/lib/libglib-2.0.so.0
/lib/libglib-2.0.so.0.2400.2
/usr/local/lib/libglib-2.0.so.0
/usr/local/lib/libglib-2.0.so.0.2912.0
/usr/local/share/gdb/auto-load/libglib-2.0.so.0.2912.0-gdb.py


In the output we can see that the newer, 2.29.12, is present ins "/usr/local/lib/" i.e. /usr/local/lib/libglib-2.0.so.0.2912.0.
So we need  to remove the older lib file in /lib and replace it with this new one.  Which can be done as follows



$ sudo  rm /lib/libglib-2.0.so.0.2400.2
$ sudo rm /lib/libglib-2.0.so.0
$ sudo cp /usr/local/lib/libglib-2.0.so.0.2912.0
$ sudo ln -s /usr/local/lib/libglib-2.0.so.0.2912.0 /lib/libglib-2.0.so.0

Now run the configure again and your error should not appear again.

Also remove all the previous libglib files from /usr/local/lib, i.e. in this case  /lib/libglib-2.0.so.0.2400.2. 

nm : Command to list the symbols in object files.

If you want to peep into an object file, and see what are the various symbols that are defines in it the command will come handy.
It takes an object file as input and lists out all the symbols, their address and in which section, text,data,uninitialized etc, is the symbol present in as the output.
For example let us assume we have an object file "hello.o" for the simple hello world program hello.c.

#include<stdio.h>
main()
{
printf("Hello world");
}


Running "nm"  on the hello.o will yield

$nm hello.o
00000000 T main
                U printf



T before "main" signifies it is in the text section and the "U" before printf means it is undefined in this code. The first column gives the value of the symbol.

namei : A command to follow pathnames

namei

The command takes as input a path or a file/directory  gives, as output, information about the file and also about the other directories in the path. If the input is a symbolic link, it will follow the link to the original file showing the path that needs to be taken to reach the original file.

For eg if we have a folder "temp" with the files one,two and three then command namei on a file can be run as follows

$ namei /home/user/Desktop/temp/one
f: /home/user/Desktop/temp/one
 d /
 d home
 d user
 d Desktop
 d temp
 - one




In the output above  the "d" in the first column informs us that the item in second column is a directory and the "-" informs that the item in second column is simple text file, thus giving us information about all the directories that lead up to the file we are interested in.
The -o option that will give information about the owners of the all the folders along the path as shown below.

$ namei -o /home/user/Desktop/temp/one

f: /home/user/Desktop/temp/one
 d root  root /
 d root  root home
 d user adm  nitin
 d user adm  Desktop
 d user root temp
 - user root one

If the file passed as the argument is a symbolic link then command will follow till the real file.
For Eg Assume that the file "two" in our example is a link to another file "four" in the Desktop.

$ namei /home/user/Desktop/temp/two


f: /home/user/Desktop/temp/two
 d root  root /
 d root  root home
 d user adm  nitin
 d user adm  Desktop
 d user root temp
 l user root two -> ../four
 d user root ..
 - root  root four

The letter "l" in the first column indicates the the file is a symbolic link, and then the entries after that is the relative path from the link to the original file.


The option -l gives output similar to "ls -l" and the option "-m" gives the permission of each file or folder.

Listing CPU details

If you want to know the details of the processor in your system, there are two ways to the information.

First is by looking into /proc/cpuinfo, this gives a lot of details, including the vendor name, the frequency,L2 or l3 cache size etc.
For eg:

$ cat /proc/cpuoinfo 
processor    : 0
vendor_id    : AuthenticAMD
cpu family    : 15
model        : 12
model name    : AMD Athlon(tm) XP Processor 3000+
stepping    : 0
cpu MHz        : 800.000
cache size    : 256 KB
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 1
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext 3dnowext 3dnow up
bogomips    : 1595.97
clflush size    : 64
cache_alignment    : 64
address sizes    : 40 bits physical, 32 bits virtual
power management: ts fid vid ttp


Another way is by running the command "lscpu". This gives lesser information than the proc entry above but has some information not available in the output of cpuinfo, like the architecture, the L1 cache details etc.

For eg:

$ lscpu
Architecture:          i686
CPU(s):                1
Thread(s) per core:    1
Core(s) per socket:    1
CPU socket(s):         1
Vendor ID:             AuthenticAMD
CPU family:            15
Model:                 12
Stepping:              0
CPU MHz:               800.000
L1d cache:             64K
L1i cache:             64K
L2 cache:              256K




lsinitramfs: Listing the contents of the initrd file system. 



The initramfs is a very basic kernel, which helps boot the full kernel . By defaul the initramfs is a gzip compressed file and one can not directly look into it without unzipping it.
lsinitramfs is a command that lists the contents of the initramfs/initrd file with out unzipping it. It only gives a list of the files and can not help in look into the contents of the file.
For rg:

$ lsinitramfs /boot/initrd.img-2.6.32 
/boot/initrd.img-2.6.32
.
bin
bin/reboot
bin/readlink
bin/sleep
bin/wget
bin/busybox
bin/dd
bin/live-preseed
bin/insmod
bin/live-reconfigure
bin/gunzip
bin/kill
bin/ipconfig
bin/nfsmount
bin/run-init
bin/eject
bin/mknod
bin/losetup
bin/sh
bin/pivot_root
bin/mkdir
bin/cat
bin/sh.shared
bin/minips
bin/fstype
bin/nuke
bin/umount
bin/cpio
bin/resume
bin/sync
bin/dmesg
bin/ls
bin/gzip
bin/ln
bin/false
bin/chroot
bin/mount
bin/true
bin/mkfifo
bin/halt
bin/poweroff
bin/rsync
bin/md5sum
bin/uname
sbin
sbin/modprobe
sbin/dmsetup
sbin/blockdev
sbin/losetup
sbin/blkid
sbin/udevadm
sbin/udevd
sbin/rmmod
etc
etc/modprobe.d
etc/modprobe.d/linux-sound-base_noOSS.conf
etc/modprobe.d/i915-kms.conf
etc/modprobe.d/fbdev-blacklist.conf
etc/modprobe.d/aliases.conf
etc/modprobe.d/alsa-base.conf
etc/modprobe.d/alsa-base-blacklist.conf
etc/modprobe.d/radeon-kms.conf
etc/modprobe.d/blacklist.conf
etc/udev
etc/udev/udev.conf
lib
lib/libacl.so.1.1.0
lib/libattr.so.1.1.0
lib/libpopt.so.0
lib/ld-linux.so.2
lib/libpthread.so.0
lib/libuuid.so.1
lib/libblkid.so.1
lib/libm.so.6
lib/live-boot
lib/modules
lib/modules/2.6.32
lib/modules/2.6.32/modules.alias.bin
lib/modules/2.6.32/modules.dep
lib/modules/2.6.32/modules.softdep
lib/modules/2.6.32/kernel
lib/modules/2.6.32/kernel/drivers
lib/modules/2.6.32/kernel/drivers/scsi
lib/modules/2.6.32/kernel/drivers/scsi/scsi_wait_scan.ko
lib/modules/2.6.32/modules.order
lib/modules/2.6.32/modules.dep.bin
lib/modules/2.6.32/modules.alias
lib/modules/2.6.32/modules.symbols
lib/modules/2.6.32/modules.devname
lib/modules/2.6.32/modules.symbols.bin
lib/klibc-wbwbg7GBhllIGBCTEv0okjVELWk.so
lib/libattr.so.1
lib/udev
lib/udev/input_id
lib/udev/usb_id
lib/udev/rules.d
lib/udev/rules.d/60-persistent-storage-dm.rules
lib/udev/rules.d/50-udev-default.rules
lib/udev/rules.d/80-drivers.rules
lib/udev/rules.d/60-persistent-storage.rules
lib/udev/rules.d/55-dm.rules
lib/udev/rules.d/91-permissions.rules
lib/udev/ata_id
lib/udev/edd_id
lib/udev/scsi_id
lib/udev/cdrom_id
lib/udev/v4l_id
lib/udev/firmware.agent
lib/udev/hotplug.functions
lib/udev/path_id
lib/librt.so.1
lib/libdl.so.2
lib/libudev.so.0
lib/libselinux.so.1
lib/libblkid.so.1.1.0
lib/libuuid.so.1.3.0
lib/libacl.so.1
lib/libc.so.6
lib/libdevmapper.so.1.02.1
init
conf
conf/modules
conf/initramfs.conf
conf/arch.conf
conf/conf.d
conf/conf.d/resume
scripts
scripts/live-functions
scripts/live-premount
scripts/live-premount/readonly
scripts/live-premount/select_eth_device
scripts/live-premount/ORDER
scripts/live-premount/modules
scripts/live-bottom
scripts/live-bottom/24preseed
scripts/live-bottom/12fstab
scripts/live-bottom/ORDER
scripts/live-bottom/30accessibility
scripts/live-bottom/08persistence_excludes
scripts/live-bottom/23networking
scripts/live
scripts/init-top
scripts/init-top/all_generic_ide
scripts/init-top/ORDER
scripts/init-top/udev
scripts/init-top/keymap
scripts/init-top/blacklist
scripts/live-helpers
scripts/local
scripts/init-bottom
scripts/init-bottom/ORDER
scripts/init-bottom/udev
scripts/local-premount
scripts/local-premount/ORDER
scripts/local-premount/resume
scripts/nfs
scripts/functions
usr
usr/lib
usr/lib/libz.so.1
usr/lib/libcrypto.so.0.9.8
usr/lib/libssl.so.0.9.8
usr/share
usr/share/live-boot
usr/share/live-boot/languagelist 


We can also view the long listing using the option "-l" with the command.

look: command to search lines begining with a string


look

look "string" "filename" 

The command "look" searhes for lines that start with a  string passed to it as an argument in the file  which is also passed as an argument and outputs the
whole line. This is similar to following grep command
grep ^"search sting" "file name" 

For eg if we have file named "one" with the contents

The weather has been cloudy
hence it is getting colder every day. 
It might rain too. 


If we want to search for lines that start with string "The" .

$ look The one 
The weather has been cloudy

By default "look" is case sensitive, to ignore case we can use an option "-f".

$look -f the one 
The weather has been cloudy