Friday, 26 December 2008

Installing Adobe Flash Player Plugin in GNU/Debian Sid

There are several available installation versions: tar.gz, deb and rpm.

I try deb package version because it solved me all unsatisfied dependencies that made iceweasel(firefox) crash.

First we download .deb package.

Now we install the package.
#dpkg -i install_flash_player_10_linux.deb

Solving dependencies problems
#apt-get -f install

You can now run iceweasel with adobe flash plugin support.

NOTE:Another way of installing this plugin is the Debian installation way:

supposing you have non-free repositories added in your sources.list file.

#aptitude install flashplugin-nonfree

It automatically installs tar.gz version from adobe page

However dependencies are not the same as .deb package and my iceweasel crashed.


Sunday, 21 September 2008

Installing GNU/Debian Sid in Ubuntu Hardy using debootstrap and chroot

This article explains how to install GNU/Debian Sid in a previously installed Ubuntu Hardy System. We will use debootstrap and chroot tools to accomplish that. This how-to is not focused on security, it does not tell how to create a restricted chroot environment to improve security.

Ubuntu is a GNU/Debian based distro. Every six months they take GNU/Debian Unstable packages and make a new Ubuntu distribution.
Debian Sid provides more and newer packages. Ubuntu is configured for easiness. Debian has less preconfiguration instead.

chroot runs a command with a special root directory.
chroot comes as part of coreutils package.
$ sudo aptitude install coreutils

debootstrap command bootstraps a basic Debian system (it can also bootstrap other systems).
$ sudo aptitude install debootstrap

$ ls /usr/share/debootstrap/scripts/ #shows which distros and versions you can install with debootstrap:

breezy  edgy  etch-m68k  gutsy  hoary  lenny  sarge  sarge.fakechroot  warty  woody 
dapper  etch  feisty  hardy  hoary.buildd  potato  sarge.buildd  sid warty.buildd  woody.buildd


First of all we create the directory where Debian Sid will be installed.
$ mkdir DebianSid


This step is only necessary if you plan to boot your system from your Debian Sid chroot environment.

$ sudo dd if=/dev/zero of=DebianSidFile bs=1048576 count=10000 #We create DebianSidFile with 10 gigabyte capacity.

$ sudo mkfs.ext3 -b 4096 -L DSid DebianSidFile #Ext3 filesystem creation.

$ sudo mount DebianSidFile DebianSid -t ext3 -o loop #mounting it on DebianSid directory.


Wednesday, 20 August 2008

Joining two AVI files with MENCODER

It is usual having an avi film split into two cdrom sized files of 700 megabytes each.

mencoder utility allows us to concatenate these two parts into a new reintegrate file.

mencoder (MPlayer's Movie Encoder) is a tool MPlayer provides to encode multimedia contents into files.
It supports among others, MPEG-4 video, libavcodec codecs, and PCM/MP3/VBRMP3 audio formats.
mencoder also possesses stream copying abilities and a powerful filter system (crop, expand, flip, ....).

So we have a film split into two files e.g: foo1.avi and foo2.avi, both with the same encoding characteristics (window size, codecs, bitrate...),

We execute this command that produces an output file called foo.avi which is the result of concatenating foo1.avi and foo2.avi files.
$mencoder -oac copy -ovc copy -forceidx foo1.avi foo2.avi -o foo.avi

The command options mean:
* -oac output audio codec
* -ovc output video codec
* -o output file name
* -forceidx forces creation of a new index.
copy means copying the original stream and do not change the codec it is encoded into (because of that it is very fast).

more info executing: $man mencoder



Split a Media Video File (AVI, FLV,...) using Mencoder and Mplayer

Convert videos to VP6 codec format using MENCODER

Friday, 15 August 2008

Downloading, Compiling and Installing MPlayer on a Ubuntu System

We are going to download MPlayer sources and binary codecs, configure, compile and install them on our Ubuntu system.

I do not want a graphical interface, so I will compile MPlayer without it.


We first download the sources: (I pick up the latest source version, if it does not work pick up latest stable one)

(I choose to download it from a German mirror: MPlayer source download page)


MPlayer binary codecs download page

As I have a Linux x86 platform ,I choose its corresponding package:

This page shows an updated list of supported codecs: Codec Status page

In order to install the binary codecs

We create the directory where we will place the codecs:
$sudo mkdir /usr/local/lib/codecs

We untar the codecs and then move them into their place:
$tar xvfj essential-20071007.tar.bz2
$cd essential-20071007/
$sudo cp * /usr/local/lib/codecs


Tuesday, 12 August 2008

Connecting to Internet using a Sony Ericsson K530i mobile phone in Ubuntu (Linux) via USB cable

We are going to connect our Ubuntu system to Internet using a Sony Ericsson K530i phone via a usb cable.

First of all we switch on our phone, we insert the pin number and then connect the usb cable that came with the phone to our K530i and to our computer.

A menu presenting three choices will appear on the phone screen:

  • File transfer
  • Phone mode
  • Print

We select Phone mode.

Now our phone is ready to use the usb cable.

There are two ways to connect to Internet via USB:
  • Emulating a ethernet device through a usb cable.
  • Using the K530i mobile phone as a usb serial modem.


Our system Linux kernel has to already be compiled with cdc_ether module support. This module performs the emulation.

Let's configure our phone, we go to:
Menu->Settings->Connectivity->USB->USB Internet->USB data accounts
and select our Internet ISP provider account.

If there is not an already configured account we shall create a new account:
Menu->Settings->Connectivity->Data comm.->Data accounts->New account

Some APNs from Spanish Internet providers are:

Yoigo: internet
Orange: internet

Usually user and password are not needed.

At the end, we establish the connection:
Menu->Settings->Connectivity->USB->USB Internet->Turn on

To check what has happened, we open a console and execute:

An interface like usb0 with its IP address correctly configured will appear.

When we finish navigating, we switch off the connection:
Menu->Settings->Connectivity->USB->USB Internet->Turn off


Sunday, 6 July 2008

Hello World program examples

Hello World is the first program every user usually codes when he learns a new programming language.

Its goal is learning the basics to edit, compile and execute a program which sends a "hello world" string to standard output.

We have used an Ubuntu Hardy distro based system. Most commands will serve to other distros as well, like Debian.

BASH Shell Scripting Hello World

bash command line interpreter is usually already installed in your system.

if it is not installed we type: $sudo aptitude install bash

Now we create script using whatever text editor we prefer.
e.g: $ gedit

Copy this lines into your script
echo "hello world"

Bash shell scripting is an interpreted language so we have not to compile anything. We directly execute the shell script file:

We give the shell script execution permissions:
$ chmod a+x

and launch the program
$ ./

PYTHON Scripting Hello World

If you do not have python installed in your system, exec:

$ sudo aptitude install python

Sunday, 22 June 2008

Emacs Quick Introduction

Installing emacs in a Ubuntu or Debian distro
$sudo aptitude install emacs

Launching emacs

If you want to launch emacs in a console without X support, simply exec:
$emacs -nw

C-x means mantain pressed control key and then press x key.

Reseting input buffer
C-g resets command input buffer. It is great if you mistyped a command.

Displacement commands:
C-n goes to next line
C-p goes to previous line
C-f goes to next character
C-b goes to previous character
C-a goes to the begining of the line
C-e goes to the end of the line

Deleting, cutting and pasting text
C-d deletes character under the cursor
C-k cuts from the cursor position until the end of the line.
C-y pastes previous cut text.

Undo command
C-x u undoes previous command.

Dealing with files
C-x C-f opens a file
C-x C-w saves current file.

Closing emacs
C-x C-c closes emacs.

Passing arguments to commands:
E.g: C-u 8 C-n Advances eight lines.

Reading emacs self-documentation:
C-h t opens emacs tutorial

These are the minimal set of commands to work with emacs like a notepad.

Emacs is an extremely powerful and flexible text editor. You are not even on the surface of emacs potential. I recommend you to study and use it.

Sunday, 27 April 2008

Backing and Restoring Mediawiki in Ubuntu

We are going to learn how to back up and restore our Mediawiki installed on a Ubuntu system.

To acomplish that we will execute some wiki maintenance commands.
These maintenance commands will be accesible after configuring AdminSettings.php file.

CONFIGURING AdminSettings.php FILE

AdminSettings.sample from the Mediawiki examples documentation will serve us as a model file to start.

We copy it into mediawiki configuration directory in /etc and assign the correct owner and permissions.
$sudo cp /usr/share/doc/mediawiki1.10/examples/AdminSettings.sample /etc/mediawiki1.10/AdminSettings.php
$sudo chown root:root /etc/mediawiki1.10/AdminSettings.php
$sudo chmod 600 /etc/mediawiki1.10/AdminSettings.php

Now we are going to edit AdminSettings.php file
$gksudo gedit /etc/mediawiki1.10/AdminSettings.php

Change these two variables using the parameters you used when creating the wiki database: e.g: wikiuser and its password.
$wgDBadminuser = 'DB user name'
$wgDBadminpassword = 'DB password'

Now that AdminSettings.php file is properly configured we are gonna back up and restore the wiki.


dumpBackup.php command will back up our wiki:
$cd /var/lib/mediawiki1.10/maintenance
$sudo php dumpBackup.php --current > ~/foo_backup.xml

NOTE: --full option backups history of pages, not only last version as --current does.


Installing and Configuring Mediawiki on a Ubuntu Gutsy Desktop System

Mediawiki is the web based tool (wiki software) that Wikipedia uses to manage, store and serve its contents.

Mediawiki is written in PHP, and in this installation we will use MySQL as database management system (although it can be configured to use PostgreSQL)

Mediawiki is ditributed under the GNU GPL license.


First step is installing MySQL:
$sudo aptitude install mysql-admin mysql-server

It will ask you for MySQL root password. Then choose a secure password and type it.

Now we install Mediawiki itself:
$sudo aptitude install mediawiki

It will automatically check for apache and php dependencies.

Current mediawiki version is 1.10.

At installation I get this warning:
apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

There is some info in this thread at ubuntu forums.

To get rid of the error:
$gksudo gedit /etc/apache2/httpd.conf

httpd.conf file is usually empty, and then we add this line:
ServerName localhost

After saving the file we check if the error is gone executing this command:
$sudo apache2ctl restart


Sunday, 30 March 2008


Executing $ ls / lists the top level of the root filesystem tree. There appear directories like:
/dev, /etc, /proc, /sys, /var, /tmp and others.

In this article we are going to deal with directories that have special filesystems associated with them.

For a general view of the filesystem hierarchy we can visit the Filesystem Hierarchy Standard page.

FHS standard is a set of guidelines about where to place files and directories within UNIX based operating systems.

Check which filesystems are mounted

Two commands allow us to examine which filesystems and where are currently mounted in our system.

$ mount
$ cat /etc/mtab

Their response will be something like that:
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.22-14-generic/volatile type tmpfs (rw)
securityfs on /sys/kernel/security type securityfs (rw)

We are specially interested in /proc, /sys, /var/run, /var/lock, /dev, /dev/shm, /dev/pts, /sys/kernel/security

/proc directory

Wednesday, 26 March 2008

Reverse Engineering Python Code with PyNSource

PyNSource is a tool that allow us to obtain UML diagrams from python source code.

PyNSource Web Page


NOTE: You must have python already installed in your system. I assume 2.5 version.

$mkdir PyNSource
$cd PyNSource

Now we download the program and install it:
$sudo python install

We want to run the GUI so we need a graphical library:
$sudo aptitude install python2.5-wxgtk2.6

Current code does not work with version wxgtk2.6 so we need to update it:
$sudo cp /usr/lib/python2.5/site-packages/pynsource/

Finally we exec the GUI module
$python /usr/lib/python2.5/site-packages/pynsource/

This application presents some annoying bugs:

* There are problems when moving shapes on the screen. It does not refresh correctly.
* It is difficult to adjust page size when you try to print it.
* When you press right click button on the mouse to delete an object, usually it doesn't delete all the arrows that point to it, messing the schema.
* Saving and opening diagram feature is not implemented yet, so you cannot save temporary work.

Well, you know, this bugs are annoying, but it you dont like them, it is free software, so hack the code. :-)

Friday, 14 March 2008

GNU Readline Library Short Description

GNU Readline is a software library that provides a set of functions that allow users to edit command lines as they are typed in.

Every program that uses this library provides the same user command line interface improving consistency between applications.

It is part of the GNU Project and it is licensed under the GPL.

Current version is 5.2 and it is used in projects like bash.

There are two editing modes available: Emacs (default) and Vi

Readline library includes additional functions to maintain a list of previously-entered command lines.
Exec this command to obtain more info about this feature:
$help history


In Debian and Ubuntu this library is packed in readline-common package.
$sudo aptitude install readline-common

Once installed, you can access a complete documentation using info command:
$info rluserman


C-k means while ctrl key is mantained pressed, depress 'k' key.
M-k means while "meta" key is pressed, depress 'k' key.

Usually "meta" refers to ALT key, but if you have no meta key you can use ESC key instead.

Emacs mode commmands:


C-b Move back the cursor one character.
C-f Move one character forward.
DEL or Backspace Delete the character placed left at the cursor.
C-d Delete the character underneath the cursor.
C-_ or C-x C-u Undo the last editing command.

C-a Move to the beginning of the line.
C-e Move to the end of the line.
M-f Move forward a word.
M-b Move backward a word.
C-l Clear the screen, reprinting the current line at the top.

Killing and yanking (cutting and pasting) commands

C-k Kill the text from the current cursor position to the end of the line.
M-d Kill from the cursor to the end of the current word.
M-DEL Kill from the cursor the start of the current word.
C-w Kill from the cursor to the previous whitespace.

After killing(cutting) text, we yank(paste) it back into the line.

C-y Yank the most recently killed text back into the buffer at the cursor.
M-y Rotate the kill-ring, and yank the new top. You can only do this if the prior command is C-y or M-y.

Searching commands

C-r Searchs backwards on the previous commands you typed.
C-s Perform a forward search from the command line history you are now.

Passing arguments to a command

e.g: M-2 3 C-d means delete next 23 characters on input line.


GNU Readline keybindings and more can be changed editing ~/.initrc or /etc/initrc files.

GNU Readline Official page
GNU Readline (Wikipedia)
Official online Readline documentation

Tuesday, 19 February 2008

Bash tips II


Sometimes you have to type a command you typed before, but you don't want to write it again, or don't remember exactly what you wrote on your command prompt.
Solution is easy, we are gonna use reverse search!

Press the keys: ctrl+r and then type part of the command you want to retype.
NOTE:It is not necessary to write the beginning of the command, you can write whatever part you want for reverse search.

If reverse search has found a command but it is not the one you were searching for, type ctrl+r again till you find it, or write a better part of the command at search time.

Now we have found the command, we have two options:
- pressing enter, the command will be executed
- pressing tab key we will be able to edit this command at the bash prompt prior to its execution.

CHANGING INTO ANOTHER DIRECTORY but memorizing where we are now in order to return later easily

This is useful if you have long weird named paths.

We are now located at foo directory:

We want to change into bar directory, instead of using cd command we use pushd
:/foo$pushd /bar

Now we are in /bar directory:

In order to return to prior foo directory we only have to run popd command.



Sometimes we want to check the blocks of a hard disk we have just bought, or whatever...

We have two options:

  • First time, when creating the filesystem with '-c' option

    e.g: mkefs.ext3 -c -b 4096 -L foo /dev/sdb2

  • If the filesystem at this partition has been already created we can use badblocks command.

    NOTE: Read carefully badblocks man page, $man badblocks before doing anything potentially harmfull.

    e.g: sudo badblocks -v /dev/sdb2