Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

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.

INSTALL APACHE


First we need apache installed in our system:

Debian:
$ sudo aptitude install apache2

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


Centos:
$ sudo yum install httpd


HOW TO LISTEN TO A PORT DIFFERENT FROM 80


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>
...
</VirtualHost><

http://httpd.apache.org/docs/current/bind.html


ENABLE REWRITE MODULE

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.

luarocks.org 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 https://github.com/pooler/cpuminer
$ 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:
$ ./autogen.sh
configure.ac:15: installing './compile'
configure.ac:4: installing './config.guess'
configure.ac:4: installing './config.sub'
configure.ac:6: installing './install-sh'
configure.ac:6: installing './missing'
Makefile.am:12: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
Makefile.am: installing './INSTALL'
Makefile.am: 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/

NOTE:
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


BTC-e.com 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


INSTALL SHA2

http://code.google.com/p/sha2

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.


INSTALL JSON

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.
http://wiki.cyanogenmod.com/wiki/Samsung_Galaxy_Mini

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.

http://developer.android.com/sdk/index.html

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


DOWNLOAD ADB TOOL

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.


INSTALLATION (DEBIAN)


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


RUNNING ED EDITOR


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


COMMAND STRUCTURE


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


Commands usually have this structure:

[ADDRESS [,ADDRESS]]COMMAND[PARAMETERS]

Commands are one letter long.

Address means to which lines command is applied to.

Parameters are passed to command.


TOOGLE THE PROMPT

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,
etc.

BitlBee official web page: http://www.biltbee.org


INSTALL BITLBEE (DEBIAN)


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


CONNECT TO BITLBEE SERVER

Sunday, 29 July 2012

Lua: Calculate a prime number list

Lua is an extension language.


This script calculates a prime number list starting with smaller ones.


To run this script you need to install lua language: (e.g: in Debian or Ubuntu)
$ sudo aptitude install lua

Current version(when this article was written) is 5.1:
$ sudo aptitude install lua5.1


After installing it, lua interpreter could be found in /usr/bin/lua.

Then you copy this script in a file, e.g: primes.lua and exec:

$ lua primes.lua 20 # it will calculate first twenty prime numbers.

or give execution permissions to the file:
$ chmod a+x primes.lua
$ ./primes.lua 20

Sunday, 20 May 2012

XWD: how to take SCREENSHOTS in X WINDOW SYSTEM


A screenshot is an image taken from the monitor screen.
It could comprise whole screen or a smaller part of it, usually a window.

XWD TOOL


X Window System provides an utility to dump images from a X Window: xwd.

xwd stores window images in a special format "xwdump".
This format can be used by other X tools too.


Other tools are also available:
convert from ImageMagick, KSnapshot, gnome-screenshot, ...


We install xwd (in debian, ubuntu):
$ sudo aptitude install x11-apps


CAPTURE WHOLE SCREEN


We could capture entire screen or some window only.
Whole screen in X Window System is associated also to a window: the root window.

Getting root window screenshots:

Sunday, 6 May 2012

Convert videos to VP6 codec format using MENCODER


This post shows how to encode a video file into VP6 codec, using mencoder program.

As a result we will create a FLV (Macromedia flash player) media file (instead of an avi file)


We will get "On2 VP6" video codec driver from a windows dll.

Mencoder is a tool provided by MPlayer to encode movies, and convert between file formats and codecs.


INSTALL MENCODER


First we obtain mencoder tool.

In debian:
$ sudo aptitude install mencoder

Current mencoder version when this article was written:
Version: 2:1.0~rc4.dfsg1+svn34540-1+b1

Another way to get mencoder could be installing from source code.


OBTAIN BINARY CODECS


Binary codecs come separately from mencoder. We can download them from MPlayer pages:
http://www.mplayerhq.hu/design7/dload.html
http://www.mplayerhq.hu/MPlayer/releases/codecs/

To see if a codec is supported:
http://www.mplayerhq.hu/DOCS/codecs-status.html


I have an amd64 architecture but I have to download ESSENTIAL CODECS for X86 anyway:
$ wget www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
$ tar xvjf essential-20071007.tar.bz2

The windows dll we need is this (check it does appear):
vp6vfw.dll


Next we place binary codecs in a directory where mplayer or mencoder can access them:
$ sudo mkdir /usr/lib/codecs
$ sudo cp -v essential-20071007/* /usr/lib/codecs/
NOTE: if you installed mplayer from source location could be: /usr/local/lib/codecs


CONFIGURING VP6 SETTINGS

Sunday, 26 February 2012

Setting up IR remote for AVerTV Digi Volar X in Debian

AVerMedia AVerTV DVB-T Volar X (A815) is an Avermedia usb device able to capture DVB-T signals.

It provides an IR remote device, which we are going to set up in this post.

To properly configure the whole device see previous post



INSTALLING AND SETTING UP LIRC

LIRC stands for 'Linux Infra-red Remote Control'.

It provides the daemons and some utilities to support infra-red remote controls under Linux.
http://lirc.org

$ sudo aptitude install lirc

We investigate about IR devices present in our system:
$ cat /proc/bus/input/devices | grep -n10 a815
187-I: Bus=0003 Vendor=0000 Product=0000 Version=0004
188-N: Name="ACPI Virtual Keyboard Device"
189-P: Phys=
190-S: Sysfs=/devices/virtual/input/input19
191-U: Uniq=
192-H: Handlers=sysrq kbd event19 rfkill
193-B: PROP=0
194-B: EV=3
195-B: KEY=ffffffffffffffff ffffffffffffffff ffffffffffffffff fffffffffffffffe
196-

Installing and setting AVerTV Digi Volar X in Debian

AVerMedia AVerTV DVB-T Volar X (A815) is an Avermedia usb device capable to capture and show DVB-T TV signals.
This device is able to also show HDTV DVB-T signals.

http://linuxtv.org/wiki/index.php/Afatech_AF9015


LINUX KERNEL DRIVER

The device contains an Afatech AF9015 Chip.
Supported in kernel since version 2.6.28.

NOTE: If you have an older kernel version you will have to compile the kernel module:
Compile AF9015 module tutorial.
AF9015 Kernel Module Source.


IMPORTANT: Although AF9015 module is already available in the kernel, it NEEDS ADDITIONAL FIRMWARE INSTALLED to work.


DETECTING THE DEVICE

I plug the usb device:

$ lsusb
... ID 07ca:a815 AVerMedia Technologies, Inc. AVerTV DVB-T Volar X (A815)

Wednesday, 12 January 2011

Calculate a PRIME NUMBER list using JAVA

This article shows how to write, compile, build and execute a program that calculates a list containing the first prime numbers using Java language.

We are going to create a source code file named CalculatePrimeNumbers.java
Then we copy/paste next programm in that file.

NOTE: Name is important, because in Java language file name has to match the class it contains.

import java.util.ArrayList;

/**
 * Description of CalculatePrimeNumbers class.
 */
public class CalculatePrimeNumbers {

    // By default it shows 50 first prime numbers.
    private static final int MAX_PRIMES = 50;


    /**
     * @param args the command line arguments
     * This function accepts zero or one arguments.
     * When called with no arguments it shows 50 first prime numbers.
     * If we specify a number, it shows that a prime number array with that specified length.
     */
    public static void main(String[] args) {
        int top;

 // Parse command line arguments.
        switch(args.length){
            case 0:
                top = MAX_PRIMES;
                break;
            case 1:
                top = Integer.parseInt(args[0]);
                break;
            default:
                System.err.println("ERROR: TOO MANY ARGUMENTS.");
                return;
        }
        System.out.println("We are going to calculate " + top + " first prime numbers.");


 ArrayList<long> primes = new ArrayList<long>();
        primes.add(2L); // 2 is the first prime number we get.
 long index = 3; // Calculations start for number 3.

        System.out.println("Prime number list:");
        System.out.print(2 + " ");
        while (primes.size() < top) {
            boolean isPrime = true;

     for(long n:primes) {
                if ((index % n) == 0) {
                    isPrime = false;
                    break;
                }
            } // End for.

            if (isPrime) {
                // index stores a prime number.
                primes.add(index);
                System.out.print(index + " ");
            }

            index++;
        } // End while.
       
    } // End main.

}
Java is a programming language that is compiled into bytecodes.

Saturday, 26 June 2010

Creating a TRIVIAL DEBIAN REPOSITORY

This howto shows the way to create a trivial debian repository. Just a simple collection of deb package files.

There are two debian repository types: automatic and trivial.

Automatic repos are more complex. We are going to deal with trivial ones.

A trivial repository is composed of a root directory and one or more subdirectories.
No database server is needed.

This trivial repository is good enough to host a few packages, e.g creating a repo with your /var/cache/apt/archives deb packages and burn a cd or store them in a removible drive.

Trivial repos do not follow the standard debian repo directory structure, so we will have to specify the exact path in sources.list file.


CREATING MY TRIVIAL REPO STRUCTURE:

Our repo will consist of MyRepo root directory with binary subdirectory.

$mkdir -p /path/to/MyRepo
$cd /path/to/MyRepo
$mkdir binary

We place there the deb packages our repo will provide.
I.e: we copy packages from the apt cache:
$rsync -vP /var/cache/apt/archives/*.deb /path/to/MyRepo/binary
$cd .. # we move to repo root directory.


CREATE PACKAGES CONFIGURATION FILE

Sunday, 25 April 2010

Building Android in Debian Sid

We are going to build and test Android in Debian Sid on x86 32 bits architecture.

As a requirement we need JDK 5.0, update 12 or higher. Java 6 is not supported, because of incompatibilities with @Override.

Debian Sid provides all packages we need except this one. We could install from source but instead we are going to install JDK 5.0 from Debian Stable (Lenny) repositories:

ADD DEBIAN STABLE (LENNY) REPOSITORIES


#echo "deb http://ftp.debian.org/debian/ stable main contrib non-free" >> /etc/apt/sources.list

#aptitude update

sun-java5-jdk package will now become available.


INSTALL ALL PACKAGES WE NEED:


#aptitude install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev


SELECT THE RIGHT JAVA VERSION:


$file /etc/alternatives/java* # To know which alternative files we have to update.
#update-alternatives --config java
#update-alternatives --config java_vm
#update-alternatives --config javaws


We also install valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.
#aptitude install valgrind

Sunday, 28 March 2010

Connect to Internet using a Sony Ericsson K530i phone in Debian GNU/Linux via Bluetooth

Within this post we are going to explain how to connect to internet using a Sony Ericsson K530i mobile phone via bluetooth, in a Debian Sid system.

CONFIGURING OUR K530i PHONE


First step consists on configuring bluetooth settings in our phone.

Activate bluetooth in the phone:
Settings -> Connectivity -> Bluetooth -> Turn on

Set a name for your phone:
Settings -> Connectivity -> Bluetooth -> Phone name
We select a name for our phone, e.g: my_K530i

Make your phone visible to other bluetooth devices:
Settings -> Connectivity -> Bluetooth -> Visibility -> Show phone


INSTALLING BLUETOOTH SOFTWARE

Sunday, 28 February 2010

How to Create a GENTOO Distro CHROOT ENVIRONMENT

This article describes how to build a chroot environment for Gentoo distribution.

NOTE: Debian GNU/Linux will be our host system, but these steps should also work for most other Linux based distributions (e.g: Ubuntu).


DOWNLOAD A SMALL MINIMUM GENTOO SYSTEM

First we are going to download a minimal Gentoo system, called STAGE3.

We choose our architecture, in my case x86, and i686 specifically.
http://mirrors.kernel.org/gentoo/releases/x86/autobuilds/current-stage3/
$ wget http://mirrors.kernel.org/gentoo/releases/x86/autobuilds/current-stage3/stage3-i686-*.tar.bz2

There is a list of mirrors here: http://www.gentoo.org/main/en/mirrors.xml

We could download directly from gentoo page too:
$ wget ftp://distfiles.gentoo.org/pub/gentoo/releases/x86/current-stage3/stage3-i686-*.tar.bz2



BUILDING OUR GENTOO DIRECTORY

We create a directory where we will place Gentoo files:

Saturday, 21 November 2009

Install and Configure quickly a DHCP Server

NOTE: These commands have been tested in Debian version unstable.

DHCP stands for Dynamick Host Configuration Protocol. This protocol allows to automatically obtain an IP address and set the network configuration.

We install a DHCP server:
#aptitude install dhcp3-server

Next step is configuring the DHCP server:
We have to set correcty the /etc/dhcp3/dhcpd.conf file.

There is a configuration file example at:
/usr/share/doc/dhcp3-server/examples/dhcpd.conf

e.g: I added these lines to my /etc/dhcp3/dhcpd.conf


subnet 192.168.1.0 netmask 255.255.255.252 {
range 192.168.1.2 192.168.1.3;
option routers 192.168.1.1;
option domain-name-servers 212.73.32.3, 212.73.32.67;
}


subnet and netmask indicate the network addresses of our network:
e.g: subnet 192.168.1.0 netmask 255.255.255.252 match 192.168.1.0, 192.168.1.1, 192.168.1.2 and 192.168.1.3 IP addresses.

range means which addresses can be returned by our dhcp server, here, it can return 192.168.1.2 and 192.168.1.3

routers indicates the gateway

domain-name-servers shows all dns addresses separated by commas.


Once we have correctly set dhcpd.conf file we restart the dhcp daemon:
#/etc/init.d/dhcp3-server restart


If everything has gone fine, we will execute in a client computer:
$sudo dhclient eth0

and the dhcp server will associate an IP adress to eth0 interface.

NOTE: dhcp3-client package provides dhclient command.
#aptitude install dhcp3-client

Sunday, 11 October 2009

How to Compile the Linux Kernel in GNU/Debian and Ubuntu

NOTE: Tested in GNU/Debian Sid. Ubuntu versions should also work.


OBTAIN KERNEL SOURCE CODE:

Obviously the first step is obtaining the source code.

It is recommended to place and build linux kernel source code in /usr/src directory, although it is not required.

We create our "Linux_Kernel_Source" directory for this task.
$mkdir Linux_Kernel_Source
$cd Linux_Kernel_Source


Linux kernel source code is freely available in Internet:
http://www.kernel.org
specifically, version 2.6:
http://www.kernel.org/pub/linux/kernel/v2.6

We download and uncompress latest source code (2.6.31 when this article was written):
#aptitude install wget bzip2 # packages needed to get the kernel source code and uncompress it.
$wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2

Uncompress the source:
$tar xvjf linux-2.6.31.tar.bz2

/usr/src/linux is a symlink to linux sources or at least linux kernel headers. It is required.
#ln -s linux-2.6.31 /usr/src/linux

$cd linux-2.6.31


KERNEL CONFIGURATION: