Aug 17 2009

Happy Birthday, Debian!

Éverton Arruda

Yesterday was Debian’s birthday, and I’d like to say:


Happy Birthday, Debian!


Aug 11 2009

Debian Day 2009 Amazonas

Éverton Arruda

Debian Day é um evento realizado anualmente por vários grupos de Software Livre em todo o mundo. Também conhecido por Dia Debian e Dia D, este evento comemora o aniversário da distribuição GNU/Linux Debian, que neste ano (2009) completa 16 anos de existência.

Em Manaus, o Debian Day é realizado pelo Grupo de Usuários Debian do Amazonas, conhecido por Debian-AM, sendo patrocinado pela UniLaSalle e com o apoio do Projeto Zagaia, AIT Technologies e Gráfica Silva.

Neste ano, teremos um desafio de programação e um convidado especial, o criador e mantenedor do site Viva o Linux (http://vivaolinux.com.br), Fábio Berbert de Paula.

Convidamos todos a participarem deste evento.
Data: 22 de Agosto de 2009.
Local: UniLaSalle, Dom Pedro I, em frente à praça de alimentação do Dom Pedro I.
Horário: 9h – 17:30h, credenciamento de 8h – 9h.
Entrada: 2Kg de alimentos não perecíveis, exceto sal.

Para saber como participar do desafio de programação, visite o site de evento.

Site: http://diadebian.org/am/2009


Jul 28 2009

Modem 3G Claro Huawei E226 no Debian Lenny/Ubuntu

Éverton Arruda

Comprei, recentemente, o modem 3G da Claro, fabricado pela Huawei, modelo E226, e infelizmente não consegui fazê-lo funcionar de cara no Debian Lenny, mas após alguns minutos de pesquisa a solução apareceu!

A solução que descreverei também funcionou do Ubuntu, nas versões Intrepid Ibex e no Jaunty Jackalope.

Você precisará do pacote wvdial, instale-o com o comando:

1
# aptitude install wvdial

Para saber mais detalhes sobre o pacote acesse este link: http://packages.debian.org/lenny/wvdial.

Após isso você deverá criar um arquivo de configuração para o wvdial, chamado wvdial.conf, com o seguinte conteúdo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[Dialer Defaults]
Carrier Check = off
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Password = claro
Ask Password = 0
Check Def Route = 1
Phone = *99***1#
Idle Seconds = 0
Modem Type = Analog Modem
Stupid Mode = 1
Compuserve = 0
Baud = 460800
Auto DNS = off
Dial Command = ATDT
Modem = /dev/ttyUSB0
ISDN = 0
Username = claro

[Dialer claro3g]
Stupid Mode = on
Password = claro
Auto Reconnect = off
Username = claro
Phone = *99***1#

conecte-se com o comando:

1
# wvdial -C wvdial.conf

E você estará conectado, mas ainda não será possível acessar qualquer endereço da internet, devido aos endereços dos servidores DNS estarem incorretos, então você deve adicionar as seguintes linhas ao arquivo /etc/resolv.conf:

1
2
nameserver 208.67.222.222
nameserver 208.67.220.220

Agora você poderá acessar a internet normalmente.

No Ubuntu, a configuração foi mais fácil devido à versão do network-manager, ao conectar o modem ao computador, este foi reconhecido normalmente e um assistente de configuração foi aberto automaticamente. Tudo o que tive que fazer para acessar a internet foi adicionar as linhas acima no arquivo /etc/resolv.conf após estar conectado, e deve ser após estar conectado porque o network-manager sobrescreve o arquivo /etc/resolv.conf toda vez.

Você pode, também, adicionar os endereços dos servidores DNS nas configurações da conexão da Claro no network-manager fazendo o seguinte: Sistemas > Conexões de Rede > Banda Larga Móvel > Editar conexão da Claro > Configurações IPv4 e adicionar os IPs 208.67.222.222, 208.67.220.220 na linha dos Servidores DNS e aplicar as alterações, assim você não terá que adicionar aquelas linhas no /etc/resolv.conf toda vez que conectar.

:wq


Jul 16 2009

VIM as a syntax highlighting pager

Éverton Arruda

I’ve been looking for a way to use less with syntax highlight and ended up in a page of Ubuntu Tutorials[0] website with a very good tip: Using VIM as a syntax highlighting pager[1].

All you’ll need is the package vim-full, só, in Debian-like systems, you’ll need to execute:

1
# aptitude install vim-full

Then, you’ll have to execute:

1
$ vim -u /usr/share/vim/vim72/macros/less.vim <FILE>

And you have it working!
NOTE: Depending on the version of your VIM, the path to less.vim might be different.

You can make this command simpler by creating an alias and adding it to your .bashrc file:

1
$ echo "alias vless=\"vim -u /usr/share/vim/vim72/macros/less.vim\"" >> ~/.bashrc

Now the system will need to re-read your .bashrc file, so the changes may be applied:

1
$ . ~/.bashrc

And after this you can test vless:

1
$ vless <FILE>

[0] http://ubuntu-tutorials.com
[1] http://ubuntu-tutorials.com/2008/07/14/use-vim-as-a-syntax-highlighting-pager/

:wq


Jul 14 2009

Colored Man Pages

Éverton Arruda

I found an interesting tip about coloring man pages in Jônatas’ blog (http://tupinigeek.blogspot.com/2009/07/man-pages-coloridas.html <- in Portugese). This is how you do it:

1 – Install most (http://www.jedsoft.org/most/index.html):
You can download most here: ftp://space.mit.edu/pub/davis/most/
or by executing the line bellow in debian-like systems:

1
# aptitude install most

2 – Export MANPAGER variable:
After this you’ll have to execute the line bellow:

1
$ export MANPAGER="/usr/bin/most -s"

Now you should have your man pages like this:

If you don’t want to export that variable everytime you restart your computer, you can add that line to your .bashrc file:

1
$ echo "export MANPAGER=\"/usr/bin/most -s\"" >> ~/.bashrc

Apr 24 2009

Linux Counter – Get counted too

Éverton Arruda
Linux Counter

Linux Counter

Surfing the web i found this project which intends to count linux users and computers running linux. Maybe you have already seen someone using “Linux User #1234567″ in his/her forum/e-mail signature, this is exactly what this project does, it counts you (if you register yourself) as a linux user.

The site shows some statistics about linux users and computers running linux, but it specifies that those statistics are not completely real, because there are many linux users not registered.

I got counted, and i’m

Linux User #489240

Linux User #489240

Get counted too!

Project Site: http://counter.li.org


Apr 16 2009

Autocompletion on VIM

Éverton Arruda

Some time ago i read, in Renato Carvalho’s Blog (http://www.renatocarvalho.net/autocompletando-no-vim-dicionario-php.html), a post about autocompletion on VIM.

Autocompletion is a method which consists of completing a word when you write part of it, for example you write lin and press a key, on the keyboard, which is programmed to execute the autocompletion and it completes the word for you, giving you linux. For me it’s very useful.

If you want it too, all you have to do is:

1 – Create plugin and doc directories in ~/.vim:

1
$ mkdir -p ~/.vim/doc ~/.vim/plugin

2 – Download and install SuperTab plugin for VIM:

This plugin enables <tab> to be used for completion.
SuperTab Link:  http://www.vim.org/scripts/script.php?script_id=1643

3 – Download functions list of a language and save it to ~/.vim/doc:

Using google you should be able to find the function list of a language.
For this tutorial i’ll use a PHP functions list, you can get it at: http://lerdorf.com/funclist.txt, save this file in ~/.vim/doc as php-funclist.txt

4 – Add a few lines inside /etc/vim/vimrc:

Edit /etc/vim/vimrc and add the following lines:

1
2
3
if has("autocmd")
    autocmd FileType php  set complete-=k/home/$USER/.vim/doc/php-funclist.txt complete+=k/home/$USER/.vim/doc/php-funclist.txt
endif

These lines tell VIM to read the php-funclist.txt file and load it for autocompletion.

You could use another language functions list, all you have to do is change the name of the functions list file from the lines above.

Now you can test it, open vim and write part of a php function, then press the <tab> key and see what happens.

This tutorial was written by Rodrigo Carvalho, i made some modifications and, with his permission, i posted here.


Apr 15 2009

Creating a simple repository for .deb packages

Éverton Arruda

A few days ago i had to create an internal repository for some deb packages. As there weren’t so many packages, i didn’t need to create a huge repository, like the official ones, so, after a little research, i managed to get it working, and that is what i will explain here, how to create a simple repository for deb packages.

We’ll need this packages before we can continue:
- apt-utils
- dpkg-dev
In debian-like systems you can install it by executing:

1
# aptitude install apt-utils dpkg-dev

And now the steps:

1 – Select the directory in which the repository will be:
I recommend you to use a direcotory in /var/www , like /var/www/repository, making it possible for everyone to see and access it without the need change apache configurations, but for this you’ll have to have apache installed.

For this tutorial we will take /var/www/repository as our repository directory.

1
# mkdir /var/www/repository

2 – Move packages to the repository directory:
Move all deb packages you want to be in the repository to the repository directory, in our case: /var/www/repository.

1
# mv *.deb /var/www/repository

3 – Create index files (Packages and Sources):
These files tell apt wich packages are available in the repository, their version, author and other informations. These files must be in the repository directory.

To create them you’ll have to run:

1
2
3
4
# dpkg-scanpackages /var/www/repository > /var/www/repository/Packages
# dpkg-scansources /var/www/repository > /var/www/repository/Sources
# dpkg-scanpackages /var/www/repository /dev/null | gzip -9c > /var/www/repository/Packages.gz
# dpkg-scansources /var/www/repository /dev/null | gzip -9c > /var/www/repository/Sources.gz

What there command do:
The first two commands scan the given directory for, repectively, .deb files and .dsc files and save their informations in, respectively, Packages and Sources.
The two last commands do the same thing, but instead of saving the files’ informations in a text file, it compresses the files’ informations and save it to a .gz file, which apt will also look for.
For more information about these commands check manpages for each one.

4 – Add repository uri to /var/apt/sources.list:
Now that you have a repository running you’ll, probably, want to access it, right?! To do that you’ll have to edit /etc/apt/sources.list .
If you want to access the repository from the same machine you’ll need to add the following lines:

1
2
3
4
# For binary files repository:
deb file:///var/www/ repository/
# For source files repository:
deb-src file:///var/www/ repository/

If you want other machines to access it you’ll have to have those machines in the same network and add the following lines in their /var/apt/sources.list file:

1
2
3
4
# For binary files repository:
deb http://repository's.machine.ip/ repository/
# For source files repository:
deb-src http://repository's.machine.ip/ repository/

5 – Check if the repository is up:
Now run:

1
# aptitude update

and see if everything is ok.

And that’s it, you should have your repository running.

TIP:
You can make a script to automatize the creation of index files, all you have to do is create a script in the /usr/bin/ directory and add the command lines for the dpkg-scanpackages and  dpkg-scansources commands:

1
2
3
4
5
6
7
# cd /usr/bin
# echo "#!/bin/bash \
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz \
dpkg-scansources . /dev/null | gzip -9c > Sources.gz  \
dpkg-scanpackages . > Packages \
dpkg-scansources . > Sources" > createrepo
# chmod +x createrepo

The script above will scan for packages and source files in the directory it’s going to be executed and you’ll have to run it as root, you could add ‘sudo’ before each dpkg-scan command so you could run it as a normal user, but it would ask you for the sudo password as well.

This tutorial was based on:
- http://ubuntuforums.org/showthread.php?t=42862
- http://www.debian.org/doc/manuals/repository-howto/repository-howto.en.html

:wq!