Archive for May, 2010


Under CentOS / Fedora / RHEL I can use rpm -ql packageName command to view contacts of .rpm file. How do I view the contents of a .deb file under Debian / Ubuntu Linux? You need to install the apt-file command which is a command line tool for searching files in packages for the APT package management system. Install apt-file # apt-get update && apt-get install apt-file Sample outputs: Reading package lists… Done Building dependency tree Reading state information… Done The following extra packages will be installed: libapt-pkg-perl libconfig-file-perl liblist-moreutils-perl menu Suggested packages: gksu kdebase-bin kdebase-runtime ktsuss sux The following NEW packages will be installed: apt-file libapt-pkg-perl libconfig-file-perl liblist-moreutils-perl menu 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 626kB of archives. After this operation, 2687kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://mirrors.kernel.org lenny/main libconfig-file-perl 1.42-1 [11.7kB] Get:2 http://mirrors.kernel.org lenny/main libapt-pkg-perl 0.1.22+b1 [89.6kB] Get:3 http://mirrors.kernel.org lenny/main liblist-moreutils-perl 0.22-1+b1 [51.9kB] Get:4 http://mirrors.kernel.org lenny/main apt-file 2.1.5 [19.2kB] Get:5 http://mirrors.kernel.org lenny/main menu 2.1.41 [453kB] Fetched 626kB in 9s (67.3kB/s) Selecting previously deselected package libconfig-file-perl. (Reading database … 21061 files and directories currently installed.) Unpacking libconfig-file-perl (from …/libconfig-file-perl_1.42-1_all.deb) … Selecting previously deselected package libapt-pkg-perl. Unpacking libapt-pkg-perl (from …/libapt-pkg-perl_0.1.22+b1_amd64.deb) … Selecting previously deselected package liblist-moreutils-perl. Unpacking liblist-moreutils-perl (from …/liblist-moreutils-perl_0.22-1+b1_amd64.deb) … Selecting previously deselected package apt-file. Unpacking apt-file (from …/apt-file_2.1.5_all.deb) … Selecting previously deselected package menu. Unpacking menu (from …/archives/menu_2.1.41_amd64.deb) … Processing triggers for man-db … Setting up libconfig-file-perl (1.42-1) … Setting up libapt-pkg-perl (0.1.22+b1) … Setting up liblist-moreutils-perl (0.22-1+b1) … Setting up apt-file (2.1.5) … You need to run ‘apt-file update’ as root to update the cache. Setting up menu (2.1.41) … Processing triggers for menu … First, resynchronize the package contents from their sources, enter: # apt-file update Task: List contents Of a Debian .deb File / Package The syntax is as follows: # apt-file list packageName # apt-file list wget Sample outputs: epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/gwget.xml epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/libgwgetextension.a epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/libgwgetextension.la epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/libgwgetextension.so epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/AUTHORS epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/NEWS.gz epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/README epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/THANKS epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/TODO epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/changelog.Debian.gz epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/changelog.gz epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/copyright gwget: /usr/bin/gwget gwget: /usr/share/applications/gwget.desktop gwget: /usr/share/dbus-1/services/gwget.service gwget: /usr/share/doc/gwget/AUTHORS gwget: /usr/share/doc/gwget/NEWS.Debian.gz ….. …… wget-el: /usr/share/emacs/site-lisp/wget-el/wget-sysdep.el wget-el: /usr/share/emacs/site-lisp/wget-el/wget.el How Do I See foo.deb Contents? Type the following command to see contents of a .deb file called foo.deb # dpkg-deb -c foo.deb # dpkg-deb -c acct_6.4~pre1-6_amd64.deb Sample outputs: drwxr-xr-x root/root 0 2008-03-08 14:26 ./ drwxr-xr-x root/root 0 2008-03-08 14:26 ./etc/ drwxr-xr-x root/root 0 2008-03-08 14:26 ./etc/init.d/ -rwxr-xr-x root/root 1787 2008-03-08 14:26 ./etc/init.d/acct drwxr-xr-x root/root 0 2008-03-08 14:26 ./etc/default/ -rw-r–r– root/root 332 2008-03-08 14:26 ./etc/default/acct drwxr-xr-x root/root 0 2008-03-08 14:26 ./etc/cron.monthly/ -rwxr-xr-x root/root 1281 2008-03-08 14:26 ./etc/cron.monthly/acct drwxr-xr-x root/root 0 2008-03-08 14:26 ./etc/cron.daily/ -rwxr-xr-x root/root 379 2008-03-08 14:26 ./etc/cron.daily/acct drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/ drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/sbin/ -rwxr-xr-x root/root 11000 2008-03-08 14:26 ./usr/sbin/dump-utmp -rwxr-xr-x root/root 12760 2008-03-08 14:26 ./usr/sbin/dump-acct -rwxr-xr-x root/root 29240 2008-03-08 14:26 ./usr/sbin/sa -rwxr-xr-x root/root 8184 2008-03-08 14:26 ./usr/sbin/accton drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/bin/ -rwxr-xr-x root/root 21592 2008-03-08 14:26 ./usr/bin/ac -rwxr-xr-x root/root 20888 2008-03-08 14:26 ./usr/bin/lastcomm drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/ drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/doc-base/ -rw-r–r– root/root 587 2008-03-08 14:26 ./usr/share/doc-base/acct drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/doc/ drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/doc/acct/ -rw-r–r– root/root 3994 2003-06-05 22:27 ./usr/share/doc/acct/README -rw-r–r– root/root 1247 2008-03-08 14:26 ./usr/share/doc/acct/copyright -rw-r–r– root/root 68845 2008-03-08 14:26 ./usr/share/doc/acct/accounting.html -rw-r–r– root/root 1601 2006-01-08 04:44 ./usr/share/doc/acct/NEWS.gz -rw-r–r– root/root 7105 2008-03-08 14:26 ./usr/share/doc/acct/changelog.Debian.gz -rw-r–r– root/root 14612 2006-01-08 04:44 ./usr/share/doc/acct/changelog.gz -rw-r–r– root/root 8534 2003-06-05 22:27 ./usr/share/doc/acct/TODO.gz drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/man/ drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/man/man1/ -rw-r–r– root/root 1655 2008-03-08 14:26 ./usr/share/man/man1/lastcomm.1.gz -rw-r–r– root/root 2381 2008-03-08 14:26 ./usr/share/man/man1/ac.1.gz drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/man/man8/ -rw-r–r– root/root 3118 2008-03-08 14:26 ./usr/share/man/man8/sa.8.gz -rw-r–r– root/root 728 2008-03-08 14:26 ./usr/share/man/man8/dump-utmp.8.gz -rw-r–r– root/root 915 2008-03-08 14:26 ./usr/share/man/man8/dump-acct.8.gz -rw-r–r– root/root 553 2008-03-08 14:26 ./usr/share/man/man8/accton.8.gz drwxr-xr-x root/root 0 2008-03-08 14:26 ./usr/share/info/ -rw-r–r– root/root 11307 2008-03-08 14:26 ./usr/share/info/accounting.info.gz You read the contents of a installed package: # dpkg -L packageName

You will find here how to discover which directory or file is using your disk space, and therefore where makes more sence to start erasing files.

This is assuming you have all partitions in one disk, if not, do not run this command at the root level, but at each mount point of every disk you have.
<!–break–>
I will apply this on my own hard disk, I have in my Desktop PC all directories on the same disk.

cd /

sudo du -s * | sort -n

Here is my result.

0       proc
0       sys
4       libsmbios_c
12      mnt
16      lost+found
20      media
36      tmp
184     dev
376     root
4356    bin
9252    etc
12007   boot
12800   sbin
70480   srv
94784   lib
332756  opt
4602136 usr
7439864 var
15018948        home

Now go let’s say to /var

cd /var

sudo du -s * | sort -n

And here is my result.

0       mail
4       empty
4       local
4       opt
8       games
8       lock
32      abs
160     run
1564    spool
8956    tmp
48228   log
112820  lib
7268072 cache

As I am using Arch Linux in my Desktop PC /var/cache is one of the biggest directory as there are stored the binaries from every upgrade I made to the system.

You can keep going inside each directory to finally find which is the one causing you running out of space.

Getting started

  • First you must install the libnotify-bin package. To do this, type in a terminal:
    • sudo apt-get install libnotify-bin
  • To see if this works, type in the terminal:
    • notify-send Test "This is a test"
  • Normally, the message “This is a test” should be displayed

Preparing the script

  • Now that the software is operational,its time to create a script with the message that will be displayed at a given moment.
  • In your home folder, create a blank file named “recall.sh” (the “. sh” is essential, instead of “recall”, you can put whatever you want)
  • In this file, write:
    • #!/bin/bash notify-send "Message title" "Message"
  • and save.

Planning the execution of script

Now you need to run a command that will plan the display of message on-screen

  • Simply type in a terminal:
    • at -f recall.sh 19:30
  • This, run the script at 19:30.
  • If you want to run a particular day, enter:
    • at -f recall.sh  19:30 Jul 10
  • It will be displayed July 10 at 19:30

Adding an icon to the message

  • You will need an image or “icon” (PNG), and then edit the file recall.sh:
    • notify-send -i /path/of_image/image.png "Message title" "Message"
  • You can create script message that will work together with Blueproximity and when person come in the house it will show they are home safe as soon they enter house or many other uses let me know if you have any other uses

monojohnny made a cool script that makes the computer beep when your phone is stolen

Howto: Use BlueProximity and your cellphone for security


And an alternative (crappy!) DIY method can be tried using the following simple shell script – I include this here for fun only. Enjoy !

— CUT HERE —-
#!/bin/sh
# “bluetooth_alarm.sh”.
# Shell script to beep annoyingly at you as your bluetooth enabled phone
# is stolen from you in your local coffee shop.
#
# Fun: 6/10 – “Quite Fun”
# Usefulness: 2/10 “Not Very”
# Phone needs to be connected via bluetooth – just ‘browse device’ initially
# From KDE bluetooth icon, then run the script.
#
# Install ‘beep’ for this to work to its full potential
# “sudo apt-get install beep”
#
# ‘Tested’ on ubuntu 8.04, Dell Optiplex GX110, with USB bluetooth dongle
# ‘lsusb’ output:
# “0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)”
# (Replace XX:XX:XX:XX with your device’s bluetooth address of course!)
QUALITY=255
while [ “$QUALITY” -ge 200 ]
do
QUALITY=`hcitool lq XX:XX:XX:XX |awk -F”:” ‘ { gsub(/ /,””); print $2 } ‘`
printf $QUALITY”.”
sleep 2
done
beep -l 100 -f 300 -r 15
— CUT HERE —

First of all: great program, great how-to! Genius idea: locking pc on bluetooth signal strength.
Instead of Amarok, I use Rhythmbox and I got it to work with Rhythmbox as well, so here’s a little how-to for Rhythmbox.

  1. Make bash scripts
    To be able to run multiple commands it is preferable to use a bash script. Let’s make some, if you don’t have already.

    1. Open up a terminal and execute the commands in the code blocks.
    2. Let’s create a blueproximity directory in your home-dir.
      Code:
      mkdir ~/.blueproximity
    3. Create the bash files.
      Code:
      touch ~/.blueproximity/lock.sh ~/.blueproximity/unlock.sh
    4. Edit the lock file:
      Code:
      gedit ~/.blueproximity/lock.sh
    5. Insert the following code:
      Code:
      #!/bin/bash
      
      # Lock the screen (default BlueProximity)
      gnome-screensaver-command -l
      # Let's pause Rhythmbox
      rhythmbox-client --pause --no-start
    6. Save and exit Gedit
    7. Likewise for the unlock script:
      Code:
      gedit ~/.blueproximity/unlock.sh
    8. Insert the following code:
      Code:
      #!/bin/bash
      
      # Unlock the screen (default BlueProximity)
      gnome-screensaver-command -d
      # Let's resume Rhythmbox
      rhythmbox-client --play --no-start
    9. Save and exit Gedit
    10. Make the bash scripts executable (and readable) for everybody by using the following command
      Code:
      chmod a+r+x ~/.blueproximity/lock.sh ~/.blueproximity/unlock.sh
  2. Let Blueproximity use your bash scripts
    1. You can now close the terminal and open up the BlueProximity preferences (at tab Locking).
    2. Use as locking command ~/.blueproximity/lock.sh and likewise for the unlocking command ~/.blueproximity/unlock.sh.

Note: The –no-start option makes sure Rhythmbox does not open an instance when there is none. Otherwise, Rhythmbox will start when (un)locking when no instance is open. See also rhythmbox-client –help.

Other possible options for the rhythmbox-client command, see rhythmbox-client –help.
I can think of lowering the volume and bringing up again, in a for-loop to increase it smoothly. Or not pausing the music when your favourite artist is playing at the moment…