Entre linhas
Little details about some work with my computer.
lunes, septiembre 13, 2010
Setup of a Ubuntu based SGE Cluster
Here.
miércoles, mayo 19, 2010
SFTP Chroot jail with OpenSSH >= 5
What does this do again...?
Lock users to their home directory: This blocks their eyes from the rest of your system and from files like: system binaries, other users' files, backups, configuration files
Disable regular ssh access: Many users just having a web site won't need an actual command interface. Its just one more thing to be hacked.
This tutorial uses Ubuntu 10.04 with the openssh server package installed. All commands must be run as root
NOTE: The jailing setup for OpenSSH ver5 is much cleaner and uses less hacks then ver4. If you need to jail users, make sure to update to version 5.
If you are looking for the tutorial for version 4, click here.
1. Install the openssh server package
apt-get install ssh
2. Change the ssh server configuration files (/etc/ssh/sshd_config)
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory /opt/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no
3. Create the sftp group
groupadd sftp
chown -R root:root /opt/sftp
chmod -R 755 /opt/sftp
4. Create a sftp user
adduser mark --ingroup sftp --home /opt/sftp/mark --shell /bin/false --disabled-password
OR
useradd mark
usermod -g sftp mark
usermod -s /bin/false mark
usermod -d /opt/sftp/mark mark
NOTE: Check the file /etc/passwd for the user settings.
5. Create the directory tree
chmod -R 755 /opt/sftp/mark
chown -R root:root /opt/sftp/mark
mkdir /opt/sftp/mark/incoming
chown mark:sftp /opt/sftp/mark/incoming
6a. Create the ssh keypair for the user if you don't enable password access (you can also change the .ssh directory paths configuring the ssh server with editing /etc/ssh/sshd_config).
ssh-keygen -b 4096 -t rsa -C mark
mkdir /opt/sftp/mark/.ssh
cp ./id_rsa.pub /opt/sftp/mark/.ssh/authorized_keys
chown -R mark:root /opt/sftp/mark/.ssh
chmod 700 /opt/soft/mark/.ssh
chmod 400 /opt/soft/mark/.ssh/authorized_keys
6b. Create a password for the user
sudo passwd mark
References:
http://librenix.com/?inode=12002
http://adamsworld.name/chrootjailv5.php
jueves, diciembre 04, 2008
Resize Tango icons SVG to PNG with ImageMagick

For example, if I wanted to resize the .svg icons to png 40x40 size:
$ for i in `find -name *.svg`; do ./svg2png.sh '-density 60 -background transparent' 40x40 $i; done;
I have changed the content of svg2png.sh to:
#!/bin/sh
SVGCONVERT="convert"
ICONTEST=`echo ${3} | grep "icon$"`
if [ ! -z "${ICONTEST}" ]; then
exit 0
fi
ICONFILE=`basename ${3}`
ICONNAME=`echo ${ICONFILE} | sed -e "s/.svg//"`
DIRNAME=`dirname ${3}`
DIRNAME=${DIRNAME#*/scalable/}
if test `basename $SVGCONVERT` = "rsvg"; then
OPTIONS="-w ${1} -h ${1}"
else
OPTIONS="${1}"
fi
OUTDIR=${2}/${DIRNAME}
mkdir -p ${OUTDIR}
echo "${SVGCONVERT} ${OPTIONS} ${3} ${2}/${ICONNAME}.png"
${SVGCONVERT} ${OPTIONS} ${3} ${OUTDIR}/${ICONNAME}.png
If you want to change to .gif or .bmp files you should change the options in the convert call and the file extensions in the end of svn2png.sh.
jueves, noviembre 27, 2008
Playing with Matlab I - HyperSpectral Images (Indian Pines)
pines = fopen ('92AV3C.no_header');
fid = fopen ('92AV3C.no_header');
x = fread (fid);
x_pie = multibandread ('92AV3C.no_header', [145 145 220], 'int16', 0, 'bil', 'ieee-be');
imshow (x_pie[:170])
slice170 = squeeze (img(:,:,170));
imshow (slice170);
slice170 = squeeze (x_pie(:,:,170));
imshow (slice170);
imagesc (slice170);
imshow (slice170, [min(min(slice170)) max(max(slice170))]);
slice150 = squeeze (x_pie(:,:,150));
imagesc (slice150);
imshow (slice170, [min(min(slice170)) max(max(slice170))]);
pixel1x1 = squeeze (x_pie(1,1,:));
plot (pixel1x1)
[coeff, score, latent] = princomp (img_vec);
latent
latent_percent = (latent/sum(latent))*100 ;
varianzas = (latent/sum(latent))*100
i = 0 ;total=0;
while total < 99.5; i = i + 1; total = total + varianzas (i); end
i
i=0;total=0;
while total < 99; i = i + 1; total = total + varianzas (i); end
i
i=0;total=0;
while total < 95; i = i + 1; total = total + varianzas (i); end
i
pareto (varianzas)
[U,P] = NFINDR(x_pie, 9);
plot (U)
[U,P] = NFINDR(zscore(x_pie), 10);
score_reshaped = reshape (score, 145, 145, 220);
plut (U);
img_abundancia = FCLSU (zscore(img), U);
figure; imshow(squeeze(score,:,:,0));
figure; imshow(squeeze(score(:,:,1)));
figure; imshow(squeeze(score_reshaped(:,:,0)));
figure; imshow(squeeze(score_reshaped(:,:,1)));
imagesc (squeeze(img_abundancia(:,:,1)));
imagesc (squeeze(img_abundancia(:,:,2)));
imagesc (squeeze(img_abundancia(:,:,3)));
imagesc (squeeze(img_abundancia(:,:,4)));
figure; imagesc(squeeze(score_reshaped(:,:,4)));
imagesc (squeeze(img_abundancia(:,:,10)));
num_endmembers = size (U,2);
imagesc (squeeze(img_abundancia(:,:,8)));
figure; imagesc (squeeze(img_abundancia(:,:,9)));
figure; imagesc (squeeze(img_abundancia(:,:,4)));
figure; imagesc (squeeze(img_abundancia(:,:,6)));
figure; imagesc (squeeze(img_abundancia(:,:,7)));
figure; imagesc (squeeze(img_abundancia(:,:,3)));
figure; imagesc (squeeze(img_abundancia(:,:,10)));
help kmeans
[idx, c, sumd, dist] = kmeans (squeeze (145,145,:), 17);
[idx, c, sumd, dist] = kmeans (reshape (img_abundancia,145*145, 10), 17);
c
imagesc (idx);
imagesc (c);
imagesc (c,idx);
imshow (c,idx);
help kmeans
imagesc(c);
imagesc(idx);
classification_result = reshape (idx, 145, 145);
imagesc (classification_result)
[idx, c, sumd, dist] = kmeans (reshape (img_abundancia,145*145, 10), 10);
classification_result = reshape (idx, 145, 145);
imagesc (classification_result);
domingo, octubre 19, 2008
ExpressCard hot plugging
Firstly I thought it could be a driver problem, but then I realized that there were no ExpressCard module running. I searched for it and also found this.
I executed: sudo modprobe pciehp, plugged in the card and it worked.
martes, octubre 14, 2008
How to work better
- Do one thing at a time.
- Know the problem.
- Learn and listen.
- Learn to ask questions.
- Distinguish sense from nonsense.
- Accept change as inevitable.
- Admit mistakes.
- Say it simple.
- Be calm.
- Smile
viernes, junio 06, 2008
Backup and sync your Firefox bookmarks with your personal server
It works pretty well.
In its configuration menu there is an option to use a personal server as bookmark sync server.
I looked for it in the internet and found this.
An article that explains how to use an FTP server to sync your bookmarks with Foxmarks.
jueves, junio 05, 2008
Cómo instalar el VMware Workstation en Ubuntu 8.04
1. Suponemos que ya habéis comprado el VMware Workstation para la versión de GNU/Linux que usáis, es decir, 32 bits o 64. La última que hemos comprado era la 6.0.3. El software viene en un paquete con extensión .tar.gz. Voy a suponer que lo tenemos en el directorio /opt .
2. Como estamos en GNU/Linux, en vez de deciros dónde tenéis que hacer clics (que es un coñazo), os voy a poner los comandos que tenéis que ejecutar. Ejecutar significa escribirlos en una terminal (se encuentra en Applications->Accessories->Terminal) y después pulsar Enter.
3. Aquí va la serie de comandos y las salidas marcadas con >> (tranquilos, no son chicas, son lo que te muestra en la terminal el programa) :
- cd /opt
- tar xvzf VMware_Workstation_6.0.3.tar.gz
- cd vmware-distrib
- sudo ./vmware-instal.pl
>> Installing VMware Workstation.
>> In which directory do you want to install the binary files?
>> [/usr/bin]
- Presiona Enter.
>> What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
>> [/etc]
- Presiona Enter
>> What is the directory that contains the init scripts?
>> [/etc/init.d]
- Presiona Enter
>> In which directory do you want to install the daemon files?
>> [/usr/sbin]
- Presiona Enter
>> In which directory do you want to install the library files?
>> [/usr/lib/vmware]
- Presiona Enter
>> The path "/usr/lib/vmware" does not exist currently. This program is going to
>> create it, including needed parent directories. Is this what you want?
>> [yes]
- Presiona Enter
>> In which directory do you want to install the manual files?
>> [/usr/share/man]
- Presiona Enter
>> In which directory do you want to install the documentation files?
>> [/usr/share/doc/vmware]
- Presiona Enter
>> The path "/usr/share/doc/vmware" does not exist currently. This program is
>> going to create it, including needed parent directories. Is this what you want?
>> [yes]
- Presiona Enter
>> The installation of VMware Workstation 6.0.3 build-80004 for Linux completed
>> successfully. You can decide to remove this software from your system at any
>> time by invoking the following command: "/usr/bin/vmware-uninstall.pl".
>> Before running VMware Workstation for the first time, you need to configure it
>> by invoking the following command: "/usr/bin/vmware-config.pl". Do you want
>> this program to invoke the command for you now? [yes]
- Presiona Enter
>>Making sure services for VMware Workstation are stopped.
>>Stopping VMware services:
>> Virtual machine monitor done
>> Blocking file system: done
>> Bridged networking on /dev/vmnet0 done
>> Host network detection done
>> DHCP server on /dev/vmnet8 done
>> NAT service on /dev/vmnet8 done
>> Host-only networking on /dev/vmnet8 done
>> Virtual ethernet done
>> Configuring fallback GTK+ 2.4 libraries.
>> In which directory do you want to install the theme icons?
>> [/usr/share/icons]
- Presiona Enter
>> What directory contains your desktop menu entry files? These files have a
>> .desktop file extension. [/usr/share/applications]
- Presiona Enter
>> In which directory do you want to install the application's icon?
>> [/usr/share/pixmaps]
- Presiona Enter
>> Trying to find a suitable vmmon module for your running kernel.
>> None of the pre-built vmmon modules for VMware Workstation is suitable for your
>> running kernel. Do you want this program to try to build the vmmon module for
>> your system (you need to have a C compiler installed on your system)? [yes]
- Presiona Enter
>> Using compiler "/usr/bin/gcc". Use environment variable CC to override.
>> What is the location of the directory of C header files that match your running
>> kernel? [/lib/modules/2.6.24-18-generic/build/include]
- Presiona Enter
>> Salen cosas de la compilación del módulo vmmon, no suele dar errores.
Hasta que no veas unas cosas sobre la network de la máquina virtual, dale a todo que Enter.
Como a los locos.
Luego cuando salgan para configurar los distintos tipos de redes. Si te pregunta si quieres configurar las redes, dile que sí.
Yo utilizo bridge y NAT, aunque en estos momentos no os preocupéis de configurarlo correctamente ya que en la aplicación es posible configurarlo en la interfaz (como a vosotros os gusta).
No instaléis el Eclipse Integrated Virtual Debugger ya que sé para qué vais a usar el VMware. Y tampoco sé muy bien para qué sirve.
Después le dices a todo que sí, otra vez, y está instalado.
Lo tenéis en Applications->Systems Tools->VMware Workstation.
martes, mayo 27, 2008
How to install Cisco VPN client for Ubuntu Hardy Heron
Primero os descargáis la versión 4.8.01.0640 desde aquí. Si queremos pasar del registro, he encontrado el archivo en la Wiki de un grupo muy bueno de investigación de la UPV.
La explicación, si la leeis hasta el final sirve tanto para amd64 como para i386.
Ahora, para mí caso en la UPV/EHU...el archivo ehu.pcf será el siguiente:
[main]
Description=conexion a ehu
Host=158.227.0.11
AuthType=1
GroupName=EHU
EnableISPConnect=0
ISPConnectType=0
ISPConnect=
ISPCommand=
Username=scpbalon
SaveUserPassword=0
EnableBackup=0
BackupServer=
EnableNat=1
CertStore=0
CertName=
CertPath=
CertSubjectName=
CertSerialHash=00000000000000000000000000000000
DHGroup=2
ForceKeepAlives=0
UserPassword=
enc_UserPassword=
GroupPwd=VPNs
enc_GroupPwd=
ISPPhonebook=
NTDomain=
EnableMSLogon=1
MSLogonType=0
TunnelingMode=1
TcpTunnelingPort=10000
SendCertChain=0
PeerTimeout=90
EnableLocalLAN=1
lunes, abril 07, 2008
Repetitive tasks
for i in `seq 0 99`; do
echo $i - I will never use copy and paste again.;
done;
jueves, marzo 13, 2008
VTK + ITK project using CMake in Ubuntu Gutsy
1. Create a directory for the project.
2. Create a CMakeLists.txt file with the content:
PROJECT( myProject )
FIND_PACKAGE ( ITK )
IF ( ITK_FOUND )
INCLUDE( ${USE_ITK_FILE} )
ENDIF( ITK_FOUND )
FIND_PACKAGE ( VTK )
IF ( VTK_FOUND )
INCLUDE( ${USE_VTK_FILE} )
ENDIF( VTK_FOUND )
INCLUDE_DIRECTORIES(
${myProject_SOURCE_DIR}
)
ADD_EXECUTABLE( myProject myProject.cxx )
TARGET_LINK_LIBRARIES ( myProject
ITKBasicFilters ITKCommon ITKIO
vtkRendering vtkGraphics vtkHybrid
vtkImaging vtkIO vtkFiltering vtkCommon
)
3. cmake .
4. make
And that is it! All the dependencies will be linked automatically, if they're found, if not it will ask you for installation.
http://na-mic.org/Wiki/images/e/ed/Insight-VTK.ppt
jueves, febrero 28, 2008
NVIDIA CUDA in Ubuntu Gutsy
The easiest way is installing Envy.
$ wget -c http://albertomilone.com/ubuntu/nvidia/scripts/legacy/envy_0.9.10-0ubuntu4_all.deb
$ apt-get install fakeroot dh-make dpkg-dev xserver-xorg-dev module-assistant dkms dpatch
$ dpkg -i envy_0.9.10-0ubuntu4_all.deb
$ envy -g
2. After successfully installing the Nvidia driver, restart the computer.
3. Install the Nvidia CUDA Toolkit
Download the Toolkit package from:
http://www.nvidia.com/object/cuda_get.html#linux
Decompress it and execute.
If you installed it in /usr/local/cuda:
- Change the /etc/ld.so.conf file:
Adding the paths:
/usr/local/cuda/lib
/usr/local/cuda/open64/lib
Then execute the command ldconfig.
- Link the binaries from /usr/local/cuda/bin in /usr/local/bin:
$ cd /usr/local/bin
$ ln -fs /usr/local/cuda/bin/* .
- Link the binaries from /usr/local/cuda/open64/bin in /usr/local/bin:
$ cd /usr/local/bin
$ ln -fs /usr/local/cuda/open64/bin/* .
3. Install the Nvidia CUDA Toolkit
Download the Toolkit package from:
http://www.nvidia.com/object/cuda_get.html#linux
Decompress it and execute.
By default it is installed in your /home directory in NVIDIA_CUDA_SDK.
In order to compile it you must install libglut3-dev package.
I will do some work with this library soon.
viernes, febrero 15, 2008
Deshabilitar la Touchpad en Ubuntu II
Así, en vez de asignar dos combinaciones de teclas para habilitar/deshabilitar la touchpad, pueda hacerlo con una sola combinación de teclas.
El script es el siguiente:
#!/bin/bash
declare STATE=`synclient -l | grep TouchpadOff | tr -d [:alpha:][===][=\ =]`
if [ $STATE -eq 0 ]; then
synclient TouchpadOff=1;
else
synclient TouchpadOff=0;
fi
Lo guardáis en un archivo en el sistema. Donde queráis, el mío está en /home/alux/switch_touchpad.
Ejecutáis el configurador del compiz.
System->Preferences->Advanced Desktop Effects Settings
En el panel de configuración general, en la pestaña Commands, ponéis la dirección del script:
/home/alux/switch_touchpad
Y en la pestaña Actions, en la parte Commands ponéis la combinación de teclas que ejecute el script, por ejemplo: Ctrl+Alt+T
Ya ves, tengo demasiado tiempo libre.
jueves, febrero 14, 2008
Deshabilitar la Touchpad en Ubuntu
Asegúrate de tener en la sección de configuración de la touchpad en el archivo /etx/X11/xorg.conf lo siguiente:
Option "SHMConfig"
En mi archivo se quedaría más o menos esto:
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizScrollDelta" "0"
Option "SHMConfig" "on"
EndSection
La opción SHMConfig habilitada permite cambiar algunos parámetros de configuración de la touchpad sin tener que reiniciar el Xserver.
Después de editar el archivo es necesario reiniciar el Xserver, o para evitar líos, reinicia el ordenador.
Para deshabilitar la touchpad tienes que ejecutar:
$ synclient TouchpadOff=1
y para volver a habilitarla:
$ synclient TouchpadOff=0
Para hacer esto más sencillo, se puede configurar un par de combinaciones de teclas para que ejecuten estos comandos.
Esto se hace muy fácilmente con el CompizConfig Settings Manager si estás utilizando el Compiz. En las Opciones generales, en las pestañas "Comandos" y "Acciones"
via: ubuntu.wordpress
lunes, febrero 04, 2008
International Clock
Para instalar el reloj internacional para Gnome, descargad la versión para vuestra distribución en http://ppa.launchpad.net/jorge/ubuntu/pool/main/i/intlclock/ .
Una vez descargado el paquete debian tenéis dos opciones:
1. La rápida
Se abre una terminal y ejecutáis:
$ sudo dpkg -i intlclock_1.0-1ubuntu0_amd64.deb
2. La menos rápida
Clic derecho en el fichero
Seleccionáis "Abrir con GDebi...".
Ya con el GDebi abierto pulsáis: "Instalar paquete"
Inserís vuestra contraseña y voilá.
pkg-config y anjuta 2
Las ventajas que tiene utilizar pkg-config es que te libras de añadir todas las librerías que te
hacen falta a mano.
pkg-config es una aplicación que busca en los directorios listados en $PKG_CONFIG_PATH (separados por ':' en linux, y ';' en Windows) archivos con la extensión .pc.
Por defecto, los directorios con archivos .pc en GNU/Linux están en /usr/lib/pkgconfig y /usr/local/lib/pkgconfig.
Dichos archivos .pc contienen información de flags, links, dependencias.... sobre las librerías instaladas en el sistema.
Prueba a ejecutar en una terminal: pkg-config --libs gtk+-2.0
O: pkg-config --cflags cairo
Esto es lo básico de pkg-config, tienes bastantes opciones más. Ya las iré describiendo si veo su utilidad.
Debemos pasar el texto resultante de la ejecución del programa pkg-config a otro programa (como por ejemplo, el gcc). Para ello basta con poner en la ejecución del gcc, la ejecución de pkg-config con comilla simple invertida: `pkg-config --libs gtk+-2.0`
En internet hay varios ejemplos de cómo hacer esto por línea de comandos con el gcc. Pero poco sobre cómo hacerlo en la configuración de Anjuta 2.
Así que para trabajar con gtk+-2.0 se debería dejar algo así:
Project->Properties:

Target properties:

El grito del gorila.
Install Anjuta 2.3.3 from sources in Ubuntu Gutsy
$ wget -c http://surfnet.dl.sourceforge.net/sourceforge/anjuta/anjuta-2.3.3.tar.bz2
$ sudo apt-get --purge remove anjuta
$ sudo apt-get autoremove
$ sudo apt-get build-dep anjuta
$ sudo apt-get install libgraphviz3-dev binutils-dev valgrind
$ sudo chown alux /opt
$ cp gtksourceview-2.1.1.tar.bz2 /opt
$ cp anjuta-2.3.3.tar.bz2 /opt
$ cd /opt
$ tar xvjf gtksourceview-2.1.1.tar.bz2
$ rm gtksourceview-2.1.1.tar.bz2
$ cd gtksourceview-2.1.1
$ ./configure
$ make
$ sudo make install
$ tar xvjf anjuta-2.3.3.tar.bz2
$ rm anjuta-2.3.3.tar.bz2
$ cd anjuta-2.3.3
$ ./configure
$ make
$ sudo make install
$ sudo cp libanjuta/.libs/libanjuta.* /usr/local/lib
$ sudo cp libegg/.libs/libanjuta-egg.* /usr/local/lib
$ sudo ldconfig
$ anjuta