Sunday, 20 July 2014

How to build a read only file server using Apache in Debian

This post explains how to create an anonymous read only file server using apache web server in Debian.


First we need apache installed in our system:

$ sudo aptitude install apache2

In my system: apache 2.4.9-2 version gets installed.

$ sudo yum install httpd


We will set our file server to listen on port 2221.

Edit /etc/apache2/ports.conf and add this line:
Listen 2221

Restart apache server:
$ sudo apache2ctl restart

After having apache listening on port 2221 we will be able to edit configuration file to add a virtual host for that port.

<VirtualHost *:2221>


Thursday, 3 July 2014

How to install Luarocks from sources in Debian

In this article we are going to install luarocks software in a Debian box.

Luarocks is a system to manage and deploy lua modules ("rocks").

It also tracks and installs needed dependencies when installing a new lua rock. official web site.

Install lua

First we need lua scripting language to be installed. (I get lua 5.2 version)

$ sudo aptitude install lua5.2

Lua development files will also be necessary to compile sources afterwards.

$ sudo aptitude install liblua5.2-dev

Get and compile luarocks source code

Get luarocks source code

Sunday, 4 August 2013

How to Build CPUMINER from Source Code in Debian

cpuminer is a miner program for Litecoin and Bitcoin cryptocurrencies. It runs on CPUs (it does not need a graphic card to run).

By default it uses scrypt algorithm, but it can be configured to use SHA-256 one.

Build cpuminer from source code:

In order to build cpuminer from source code we will download its source code from its repository:
$ sudo aptitude install git
$ git clone
$ cd cpuminer
$ less README

Next we install some dependencies to be able to build it.
$ sudo aptitude install automake
$ sudo aptitude install pkg-config
$ sudo aptitude install gcc
$ sudo aptitude install make

NOTE: without this package: "possibly undefined macro: AC_MSG_ERROR" error appears
$ sudo aptitude install libcurl3-gnutls-dev

Create configure and Makefile files:
$ ./ installing './compile' installing './config.guess' installing './config.sub' installing './install-sh' installing './missing' warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS') installing './INSTALL' installing './depcomp'

Build the sources:

Sunday, 23 June 2013

How to Create a shared Git Repository in Debian (ssh, git-daemon, gitweb)

Git is a distributed revision control system.

We are going to create a remote shared git repository and add the following functionality to it:

- Read and write access using ssh protocol.
- Anonymous read only access via git-daemon.
- Browse every git repository via web.
- Send an email notification when user pushes a commit.

This article shows how to set a Git repository in a Debian distro (Sid).

Create the repository in the remote machine

First we are going to configure the remote machine where the git repository will be installed.

Create a directory where we will place every git repository:
$ mkdir /gitrepo

Install git
$ sudo aptitude install git

Every user able to read and write to the git repository must pertain to gitgroup group.
$ sudo groupadd gitgroup
$ sudo chgrp -R gitgroup /gitrepo
$ sudo chmod g+w /gitrepo

Generic home for users pertaining to gitgroup group:
$ sudo mkdir /home/gitgroup
$ sudo chgrp -R gitgroup /home/gitgroup

We add our current user to gitgroup group.
$ sudo adduser my_user gitgroup
Changes will become effective after login in again.
$ groups
my_user sudo gitgroup

We create now a bare git repository
$ cd /gitrepo
$ git init --bare --shared=0664 my_git_project
Initialized empty shared Git repository in /gitrepo/bar/

0664: other user has read only permissions.
0660: other user has no permissions.

$ chgrp -R gitgroup my_git_project

--shared option sets directories, new files etc to the right permissions.

Now we have a bare repository where we could upload our commits or another preexisting repository.

Read and write access

Sunday, 16 June 2013

How to call BTC-e API using LUA language is a web site where you can exchange virtual coins (like bitcoins, litecoins, etc), US dollars, euros and Russian rubles.

It provides a web interface for you to manually interact with.

Also if you are interested in building a bot to perform operations automatically, you could use their API.

In this article I am going to call the API from my Debian Sid system using Lua language.

Install Lua and dependencies

First I install lua 5.1 and luarocks to manage lua rocks.
$ sudo aptitude install lua5.1
$ sudo aptitude install luarocks

Once luarocks is already installed I install luasockets, and luasec. This will allow us to perform request using https protocol.
$ sudo luarocks install luasocket
$ sudo luarocks install luasec


Next we install sha2 rock to calculate hmac sha512 hashes.
$ sudo luarocks install sha2
$ cd /usr/local/lib/luarocks/rocks/sha2
$ sudo aptitude install lua-filesystem
$ sudo aptitude install lua5.1-md5-dev

Now we perform the tests:
$ lua test_sha2.lua
$ lua test_hmac.lua
They should pass OK.


Saturday, 10 November 2012

How to SPLIT BOOT.IMG file into kernel and ramdisk.gz (Android)

This article shows how to split a boot.img file into kernel and ramdisk parts.

In Android systems kernel and initial ramdisk filesystem are usually joined into an only file, named boot.img, and flashed into the device.

Recover image files have same structure too.

mkbootimg is the tool which builds a boot.img file from its kernel and ramdisk parts.

Boot.img file could also contain a second filesystem within it.

Split boot.img file using a python script

Copy code at the end of this article in a file named

Then execute (you need to already have a boot.img file):
$ python -i boot.img -o parts # This splits boot.img, create parts directory and stores there zImage (kernel) and ramdisk.gz.

Saturday, 13 October 2012

How to build Android CyanogenMod 7.2.0 for Samsung GT-S5570 tass phone from source code in Debian

This article shows how to build CyanogenMod 7.2.0 (Android fork) from source in Debian Sid (October 2012) for a Samsung GT-S5570 (tass) mobile phone.

7.2.0 is the stable CyanogenMod version for tass device.

First we create a directory to place everything there:
$ mkdir ~/mydroid
$ cd ~/mydroid

Download Android SDK

The Android SDK will provide us developer tools and libraries necessary to build our Android based system.

We choose linux platform and download a tar gz file.

Then to install the Android SDK we uncompress it and export the paths of tools and platforms directories.
$ tar xvzf android-sdk_r20.0.3-linux.tgz
$ export PATH=~/mydroid//android-sdk-linux/tools:~/mydroid/android-sdk-linux/platforms:$PATH


We have downloaded basic SDK. But it lacks some required tools like adb, etc.

To upgrade Android SDK in console:
$ android update sdk --no-ui

or using a graphical interface
$ android update sdk

It fetches some xml files and starts downloading Android SDK Platform-tools and some documentation.

We export the path to recently added SDK platform-tools:
$ export PATH="~/mydroid/android-sdk-linux/platform-tools:$PATH

Now adb tool is in our PATH.

Install required Debian packages

Sunday, 23 September 2012

ED line editor - tutorial

Ed is a line-oriented text editor.

It can be used interactively or in shell scripts.

Ed is the original text editor for Unix. It was written by Ken Thompson in 1971.

Ed is a small editor with few dependencies that can help you edit some files in situations where no other editor is usable.


$ sudo aptitude install ed
$ which ed
$ ed # run ed program.


$ ed file_name # opens file_name for editing. Changes are not stored until w command is introduced.


Ed works by accepting commands to edit parts of the file.

Commands usually have this structure:


Commands are one letter long.

Address means to which lines command is applied to.

Parameters are passed to command.


Monday, 17 September 2012

LUA PRIME CALCULATOR using preprocessing based on Sieve of Eratosthenes

This article shows a lua script to calculate an ordered prime list starting with 2, 3, 5, 7, etc.

We are going to improve former lua prime calculator using a preprocessing table.
This table will allow us to discard quickly some numbers and its multiples.

Within this lua script, first we perform some preprocessing, and after that actual prime testing for remaining numbers are performed.

Sieve of Eratosthenes

Sieve of Eratosthenes is an algorithm to calculate a prime number list up to a chosen number.

In this program we will use this algorithm to generate a preprocessing table.

Some examples are useful to show how preprocessing table works:

Tables are generated using a sequence with first prime numbers.


Preprocessing table for 2


So we will test numbers this way:
We start with number one, and sum to it the first number from preprocessing table:
1+2 = 3 (3 is the next number to test for primality)

Once preprocessing table has completed, we start from first element again (2):
3+2 = 5

5+2 = 7

Monday, 10 September 2012

How to set Bitlbee (GTalk and Twitter) in Debian

BitlBee is an IRC gateway to other instant messaging networks which use different protocols (e.g: jabber, ICQ, AIM, MSN, etc)

From user point of view BitlBee acts as an IRC server which forwards your messages to other networks like Google Talk, Facebook, Twitter, Identica,

BitlBee official web page:


When writting this article current BitlBee version in Debian unstable was 3.0.5
This version allows us to authenticate using OAth.

$ aptitude show bitlbee
Package: bitlbee                         
Version: 3.0.5-1.1
Description: An IRC to other chat networks gateway (default version)

Install BitlBee IRC gateway:
$ sudo aptitude install bitlbee

If after configuring it we need to restart Bitlbee daemon
$ sudo service bitlbee restart