Thursday, September 27, 2012

Getting wiringPi on the Pi

wiringPi is one of the various libraries available for the raspberry pi to interface with hardware. It is similar to the wiring library for the arduino.

One barrier to adoption seems to be the complexity of the installation.

In reality, it is not that hard, but you need to have setuptools for python installed, the development package for python and git.

Then you get the code from git and do a setup install, but there is one hiccup: there is a c source file that needs to be edited. But you are a Python person, so dont panic, I provide a 1 line sed command to do the edit for you.

Altogether, here is what you need to do:

sudo apt-get install python-setuptools python-dev git-core
git clone
cd WiringPi-Python
git submodule update --init
sed -i 's/<wiringPi.h>/"wiringPi.h"/g' WiringPi/wiringPi/piNes.c
sudo python install
Either you run these commands one by one, or using your favorite editor, you save the whole block in a file (let's call it installwpi) and then:

pi@raspberrypi ~ $ sh installwpi

Tuesday, September 25, 2012

Editores de Codigo (X)

Hablamos la semana pasada de vim como editor de código , y lo que hacer para ver el código Python con colores.

Ahora hablamos de editores en modo gráfico (con X)

Mi favorito es Scribes, pero vamos a ver 5 en total, hoy.


Stani's Python Editor (

 pi@raspberrypi ~ $ sudo apt-get install spe


Editor de Gnome (

 pi@raspberrypi ~ $ sudo apt-get install gedit


Editor basado en GTK2 ( )

Es necesario  hacer la instalación de xterm también.

 pi@raspberrypi ~ $ sudo apt-get install geany xterm


Editor de código y HTML5 (

 pi@raspberrypi ~ $ sudo apt-get install bluefish


Editor ultra minimalista (

 pi@raspberrypi ~ $ sudo apt-get install scribes

Hay una versión mas reciente también en launchpad. Como cambia a cada día, es posible que no opera bien esta versión, pero es la versión que estoy utilizando.

La instalación de esta versión es así:

 pi@raspberrypi ~ $ sudo apt-get install python-xdg bzr autoconf automake intltool gnome-doc-utils
 pi@raspberrypi ~ $ bzr branch lp:scribes

 pi@raspberrypi ~ $ sudo su

 # cd scribes

 # ./configure

 # make
 # make install

Monday, September 24, 2012

Pas chmod, Groupes!

Je vois souvent des messages sur les forums, ou encore dans les tutoriels, la mention de chmod pour régler tel ou tel problème.

C'est assez risqué de faire cela, particulierement si on donne plein accès (777) a tous.

Ou sinon, on suggère d'utiliser sudo pour rouler son logiciel.

Mais en réalité, il suffit de bien comprendre un concept bien pratique avec Unix: les groupes.

En effet, quand on voit:

fdion@raspberrypi ~ $ ls -al /dev/fb0
crw-rw---- 1 root video 29, 0 Dec 31 1969 /dev/fb0

Les permissions sur ce fichier se découpent ainsi:
c, proprio (root): read write, pas d'exec, groupe (video): read write, pas d'exec, et les autres: aucun accès.

Si je veux que mon user fdion puisse lire et écrire le framebuffer ( par example pour tout les programmes qui utilisent la librairie SDL), il suffit de faire:

usermod -a -G video fdion ajoutant ainsi l'usager fdion au groupe video.

Et c'est tout. En passant, pour SDL je suggère de faire:

sudo usermod -a -G video fdion
sudo usermod -a -G audio fdion
sudo usermod -a -G input fdion

Pour couvrir l’accès a la vidéo, l'audio et la souris.

Sunday, September 23, 2012

Day 3

Video (and audio)

In the previous article, entitled Day 2, we talked about the keyboard as item #3.

So the Pi has 2 ways of outputing video (well, 3 if you include the DSI connector on the motherboard, but no practical of using it right now). An HDMI port:

And an RCA connector with a composite signal:

Today we are talking about hooking up your Pi with a plain old TV.

It is important to make a note that the default mode of operation of the RCA composite video out on the Raspberry Pi is NTSC which is mainly used in North America. This page link will take you to the details to change the mode to PAL or PAL as used in Brazil or NTSC as used in Japan. If your TV is autosensing, it might be irrelevant, but if not, simply change the mode in the /boot/config.txt file (sdtv_mode= 0, 1, 2 or 3).

If you look at the back of a TV, you will see one or more RCA connector. if there is only one it will propably be yellow and say video in. Some have multiple:

Still, we want to connect to video in. Since we also have audio in, as a bonus we connect the sound too (else we would need to plug headphones in the audio jack on the Raspberry Pi):

And these are the two cables and the adapter you will need to connect to the Pi:

And finally, how it connects to the Pi:

It works!

And finally, one more example of connection on the TV side (a smaller portable unit), the yellow is video and the black connector is audio, left and right channels.

All we need now is the Pi. As a FYI, MCM and Adafruit in the US seem to be shipping very quickly (a few days to receive).

So, why did I number these articles Day 0, Day 1 etc (starting at zero instead of one)? To get you used to a fundamental thing. Computers start counting at zero. If you try to do a bit of Python (maybe your motivation for buying a Pi), you will encounter all kinds of situations where you have to think in these terms (if you want to go a bit deeper on this, I suggest reading Dijkstra).

Day 2


In the previous article, entitled Day 1, we talked about the SD card as item #2.

The next item on our list was a keyboard. This one is relatively easy, but as always it is a good idea to look at the official list before buying one. The main thing to look at is the power consumption. You will want one that draws 100 mA or less from the USB bus.

Most USB keyboards work without a problem, most Dell, HP, Logitech etc, including this classic Sun type 6 USB:

But wait... USB? that is right. PS/2 keyboards won't work, as the Raspberry Pi doesn't have a ps/2 port. A USB keyboard has a cable like this:

And that end is simply connected to the Raspberry Pi's USB port (one or the other, it doesn't matter). Shown here, the grey cable at the bottom (red is network, black is audio and yellow is video):

But it is also possible to use a wireless keyboard, such as this one:

These have a USB dongle, sometimes with a button. Another advantage is that they also come bundled with a mouse. They use a proprietary protocol, but as far as the computer goes, it sees a regular USB keyboard.

There is one more keyboard type available that can be used with the Pi, and that is the Bluetooth keyboard (shown with a Bluetooth dongle):

 This is both more expensive and harder to use so we will cover that in the future when we talk about Bluetooth.

Next up, the TV.

Friday, September 21, 2012

Um centro de entretenimento por $75

Um centro de entretenimento (muito pequeno) por USD$75.

Raspberry pi                 $35
Cartao de memoria SD $11
bateria USB 5V               $6
Televisao LCD               $18
cabo de video                  $0.99
OS Raspbian                    $0
XBMC                               $0
MPEG-2                            $3.90

Total US                        $ 74.89

Mas, eu estou em falta uma remota e uma bateria de 12V (ou liga-lo no carro). Ele (Raspberry Pi) funciona para quase 1 hora com bateria USB.

Comparar o tamanho de um iPhone:

O próximo artigo em português será de cerca de e conexãos de banco de daos, para responder a esta pergunta:  [] Open and Close a database connection in a request

Editor de codigo Python (texto)

Muchas veces, debo hacer cambios, o escribir por completo un script (secuencia de comandos) Python a través de una conexión ssh. Sin X forwarding tampoco, y por eso no puedo utilizar un editor grafico.

Hay nano y vi en la distribución Raspbian Wheezy, pero, hay algo mejor: vim. En la mayoría de las distribuciones Linux y en OpenIndiana, vi es en realidad vim, pero en Raspbian, vi es vi. Vamos a ajustar eso:

fdion@raspberrypi ~ $ sudo apt-get install vim
Y tambien hay que anadir a .vimrc (en /home/user):

syntax on
filetype indent plugin on
set modeline

fdion@raspberrypi ~ $ pwd
fdion@raspberrypi ~ $ ls .vimrc
Muy bien, ahora es mas facil a leer el codigo Python en color:


Hay tambien que anadir una linea con instrucciones para vim:

La primera linea es siempre la "shebang":

#!/usr/bin/env python

Despues, una docstring (descripcion) del fichero entre """ y """. La septima linea (en nuestro ejemplo) es para vim:

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

Voy a anadir otra linea tambien, en espanol, frances y portugués, a causa de los acentos debemos poner el codigo:

# vim: set fileencoding=utf-8


Thursday, September 20, 2012

L'overclocking du Pi

La nouvelle version de Raspbian Wheezy change un peu le mode d'operation de l'overclocking.

On peut choisir le niveau d'overclocking par le menu raspi-config:

Une fois que l'on redemarre:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Ca nous donne 700000, soit 700,000 KHz ou encore 700 MHz. Mais j'ai choisi 800, non? C'est un overclock dynamique.

Il faut mettre une charge sur le cpu, ce que je fais avec un petit script python tout simple (le mettre dans un fichier

#!/usr/bin/env python
# -*- coding: utf-8 -*-
CPU - a cpu load script for the Raspberry Pi.
EN: Makes it easier to test for cpu clock speed, when overclocking.
FR: Permet de mettre une charge sur le processeur, pour verifier l'overclocking
ES: Nos ayuda a ver si el overclocking opera o no con una carga del CPU
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

import math

# Takes about 18s on the Pi
for i in range(2000000):
    x = math.sqrt(i)

Seules les 2 dernieres lignes font le boulot, une boucle de 2,000,000 de fois a calculer la racine carree. Ah oui, et l'import math car c'est une option. Le reste, c'est juste ce que je fais 100% dans tout mes scripts python.

Quand il roule (python ou encore direct ./ si on chmod +x on voit bien le 99% sous top:

Tasks:  60 total,   2 running,  58 sleeping,   0 stopped,   0 zombie
%Cpu(s): 99.7 us,  0.3 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:    189104 total,   176760 used,    12344 free,    13604 buffers
KiB Swap:   102396 total,        0 used,   102396 free,   102376 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND          
 3456 fdion     20   0 42940  34m 2368 R  99.0 18.8   0:10.61 python           
 3453 fdion     20   0  6348 1368 1044 R   0.7  0.7   0:00.42 top              
 3442 fdion     20   0 10552 1520  892 S   0.3  0.8   0:00.10 sshd             
    1 root      20   0  2136  732  624 S   0.0  0.4   0:01.63 init             
    2 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kthreadd         
    3 root      20   0     0    0    0 S   0.0  0.0   0:00.00 ksoftirqd/0      
    5 root      20   0     0    0    0 S   0.0  0.0   0:00.28 kworker/u:0      
    6 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 khelper          
    7 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kdevtmpfs        
    8 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 netns            
    9 root      20   0     0    0    0 S   0.0  0.0   0:00.01 sync_supers      
   10 root      20   0     0    0    0 S   0.0  0.0   0:00.00 bdi-default      
   11 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kblockd          
   12 root      20   0     0    0    0 S   0.0  0.0   0:00.23 khubd   

 fdion@raspberrypi ~/python_projects/load $ ./ &  
 [1] 1987  
 fdion@raspberrypi ~/python_projects/load $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq  
 fdion@raspberrypi ~/python_projects/load $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq  
 fdion@raspberrypi ~/python_projects/load $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq  
 [1]+ Done          ./  

800000 c'est 800,000 KHz ou 800 MHz.

Donc ca fonctionne.

Il est aussi possible de forcer l'overclock sans le mode econome en ajoutant la commande force_turbo = 1 dans le /boot/config.txt.

Wednesday, September 19, 2012

XBMC on Wheezy

Here are my install notes (notas durante mi instalación):
sudo su


dpkg -i libcec_1.8.0-1_armhf.deb

apt-get install liblockdev1


apt-get install libplist1 libmicrohttpd10 libtinyxml2.6.2 libyajl2 libssh-4 libmysqlclient18 liblzo2-2 libfribidi0 libcurl3-gnutls

dpkg -i xbmc-20120917_1rpb-1_armhf.deb

echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules

usermod -a -G video [fdion] (replace [fdion] by your user, like pi)

cp /boot/arm128_start.elf /boot/start.elf (we need a 128/128 memory split) 


To start:
$ /usr/lib/xbmc/xbmc.bin

Systema embebido

A veces, tengo que hacer un poco de trabajo con computadores en lugares remotos, o en sitios de construcción. Por eso, tengo una mesa en mi hackermobile (una guagua Dodge 2500 ), varias conexiones 110V, 12V, 5V usb (ver Day 0 - es en ingles, pero hay un selector de lenguaje a lado derecho, aunque la traducción de google es muy debil, lo siento )y una alimentación de portátil que opera directamente en 12V.

Asi, todo lo que tengo que hacer, es traer mi portátil. Con un laptop, obviamente, uno puede hacer muchas cosas. El sistema de operación OpenIndiana me permite de hacer una simulación de todo mi  centro de datos. Pero a veces, hay necesidad de un servidor físicamente separado del portátil. En un vehículo, un servidor de 250W-500W es algo problemático, porque requiere demasiado poder eléctrico, lo que implica:
  • capacidad de baterías muy grande
  • necesidad de aire condicionado
Es mucho mejor un servidor que consume poca electricidad. Cual eligir? Como es un blog sobre el Raspberry Pi, no hay sorpresa si estoy eligiendo un Raspberry Pi... En vez de 250W, hablamos de menos de 5W!

Audio / Video

El senal audio y video se connecta a un conmutador vídeo automático.

Aunque es mas complicado que raspberry pi -> tele, la razon es que tengo tambien un tuner, un WDTV etc. El WDTV y el Pi comparten un almacenaje, pero quizás en el futuro el Pi se sustituira como "media center" también.

El orden de prioridad del conmutador hace que si el WD y los otros dispositivos (cam etc) están apagados, el señal de la salida del conmutador es el del Raspberry Pi.

Como servidor, en realidad, no es necesario todo eso. Pero es muy practico para asegurarse que el Pi opera bien, y también voy a anadir mas funcionalidad en el futuro (OBDC, nivel/capacidad de mis batería, etc).


En cuanto a la red, es muy sencillo:

Detrás de la tele, hay un punto de acceso a la red (wan, 5 port lan y wifi), el portátil se conecta Wifi, y el Raspberry Pi con cable cat 5. DHCP hace que todo es automático.

Tuesday, September 18, 2012

SmartOS on Pi?

An interesting suggestion is mentionned here:

SmartOS on the Raspberry Pi. That would be awesome.

What time is it?

The Pi doesn't have a real time hardware clock, in order to save $$. But that doesn't mean you cant have date returning the correct time.

ntp client is installed by default. All I do when I configure a box is to add a local time provider:

fdion@raspberrypi ~ $ sudo vi /etc/ntp.conf

where it says:
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
I added:

Instead of, choose one that is close to you from this list:

fdion@raspberrypi ~ $ sudo /etc/init.d/ntp restart

[ ok ] Stopping NTP server: ntpd.
[ ok ] Starting NTP server: ntpd.

fdion@raspberrypi ~ $ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================      .INIT.          16 u    - 1024    0    0.000    0.000   0.000   2 u    8  128  357   84.964   -7.069  12.917   2 u   80  128  367   33.450    1.298   1.592
+ponderosa.piney     2 u    9  128  357   47.021   -2.056  28.562
*      2 u   17  128  377   57.341    1.629   4.500

The other thing we have to fix is the timezone. Maybe you are in the right default timezone, but more than likely (statistically more probable) that you are not. So how do we adjust this?

fdion@raspberrypi ~ $sudo dpkg-reconfigure tzdata

Current default time zone: 'US/Eastern'

Local time is now:      Tue Sep 18 18:01:43 EDT 2012.
Universal Time is now:  Tue Sep 18 22:01:43 UTC 2012.


Let me check the LCD display (driven by the GPIO pins):

This particular Pi runs headless, so that's pretty convenient to get the dhcp assigned IP. I do have to make this a little bit more permanent, although I will switch to a different display (which I also have) that will give me a little more feedback. I'll post about how to do all this soon enough.

Monday, September 17, 2012

Less work, but fools google

So, I'm switching back and forth between languages on the same blog. Makes it easier to maintain just one blog instead of 3, 4 or more with the same content but in different languages (like I do for Solaris Desktop.

Having said that, it will not work with google translate, this way. Sorry for english readers, Google thinks the whole blog is in english, so you wont be able to use the translate widget I added for the whole blog. In fact, I tried the blogger translate widget too, but it will not offer english at all. So I thought I'd be clever, and add this:

<script src=""></script>

The key here is source_language = auto. Unfortunately it complains the page is already in english...

To get around this, just select a specific article so that only one language is showing up on the page, and then you can use the translate tool.

Un ecran de portable pour le Pi

Sur le forum francais de on pose la question, que faut-il pour utiliser un ecran LCD de portable avec le Pi.

 Les portables ont une interface video interne LVDS, le Pi lui veut soit composite, soit HDMI. Et finalement, les kits pour "hacker" qui incluent un pilote LVDS, un paneau de controle pour le OSD, le convertisseur pour CCFL (pour LED, c'est different) et tout les cables de connexions, eux, sont en general VGA.

Si on va vers le plus haut de gamme comme ce pilote LVDS avec entrees DVI et HDMI:

Le probleme la c'est que ce n'est pas un kit, alors il faut se procurer les autres modules et cables, et avoir les bons. En plus, ces modules doivent etre programmes en fonction de la dalle LCD. Et il y a la question d'espace, ou mettre tout cela:

Le pilote ici requiert un module de programmation pour faire les ajustements. C'est facile de depenser plus de 100 euros (200 si on achete le module de programmation) au total, alors il faut voir si ca vaut vraiment la peine...

Sunday, September 16, 2012

En francais

Je vois que j'ai des visiteurs du Canada et de France. Je ne vais pas faire comme SolarisDesktop que j'ai aussi ecrit en francais et en espagnol. C'est trop de boulot d'ecrire trois blog a chaque fois. Mais plutot, je vais alterner entre les differentes langues et couvrir des sujets differents.
Ca me permettra aussi d'y aller en Portugais et Russe et d'ameliorer mon niveau de communication dans ces langues.
Alors, lecteurs, je vous passe la parole, que voulez-vous savoir sur le Raspberry Pi? Laissez le moi savoir en commentaire.
Oh, et soit dit en passant, il y a un forum pi en francais sur le site officiel. On le retrouve ici: forum en Francais

Saturday, September 15, 2012

Day 1

SD Card

In the previous article, entitled Day 0, we talked about all the stuff you need before your Raspberry Pi can be up and running. We talked about the power supply as item #1.

Item #2 was the SD memory card (in blue on the picture):

This is the equivalent to a hard disk on a computer, for your raspberry pi. The official distribution (operating system), raspbian wheezy, requires a minimum of a 2GB SD card. These can be had for a few $. Less than $5 at any rate. But it is not worth the time. Start at least with 4GB. Considering that an 8GB card is to be found in brick and mortar stores for $8 and a 16GB for $14 (i'm writing this in september 2012), I'd even go with 8 or 16 if this is more than a toy.

If you go with a different distribution, such as the adafruit Occidentalis distro, then you have no choice but to go with 4GB as the minimum, and there it makes also a lot of sense to get an 8GB or 16GB card.

Having said that, there are also specialized distributions, one trick ponies so to speak, that can fit on 1GB and 2GB cards. It all depends what you want to do with your Pi.

Beside the capacity, you'll want to get the right speed, or "class". For example the blue sandisk 16GB on the picture above is a class 4 card. That is a minimum speed, imho. If you can get class 6 or 10, that is even better:

This one is a SanDisk 16GB also, but a class 10 that promises 30MB/s and that's a good thing.

Buyer Beware

Before rushing out and buying a card, I do want to mention a few things.

1. Not all cards are compatible. Check the LIST and make sure that it is supported. I've never had any problem with any SanDisk or AData cards with the Raspberry Pi, but apparently some people have had issues.

2. You will need a way to write the SD card. That means either an on board SD card slot (such as on the Mac mini and mac books) or a USB SD card reader like this:

This should work with Windows, Solaris / OpenIndiana, Linux and Mac OS/X. Typically, I've found that a lot of embedded SD slots, such as found on Sony Vaio (with the secondary slot for MagicGate) and Dell Precision laptops, tend to not create reliable images, under any OS. The USB on the other hand seems solid. In the end, the embedded SD slot on my Mac Mini seems rock solid as far as that, so I tend to stick to that.

3. The steps to copy the operating system software image to the SD card is a bit involved. If that scares you, there is another option:

Buy a card that already has the OS on it. This can be found on forums, through your local hackerspace, your local Linux user group, ebay, electronic distributors (in the case of Adafruit, they sell SD cards with their own distribution, Occidentalis, already installed) or online shops that specialize in the Raspberry Pi. You can also check the LIST for some other suggestions.

So, we are making some progress... Next time, we'll talk about the keyboard.


Meet the SolarPi!

...look inside...

There is a raspberry pi in there, under the tray. Note the red key, that's a safety feature, cause this is not a toy. I reckon that I could probably run it a whole week non stop purely on batteries.

I built this a few years ago, from a toolbox on wheels.

I'm using sealed lead acid batteries (7 x 12v currently for 49Ah capacity, but 12 x 12v 7Ah for 84Ah total capacity, at some point in the past), lots of wires.

The wires are connected together with 2 rails with screws to have a common parallel connection. These are typically used for ground buses for fuse boxes. Negative side:

Positive side:

Safety first, there is a key to close the circuit. Amp meter is always on, while the voltmeter engages with the switch in the middle pulled. Yeah, I know 50 amps is crazy for the Pi, considering is pulls about 4.2 watts (less than half an ampere at 12V) without wifi or 6.8 (just a tad over half an ampere) with wifi active and transmitting. But I've designed this initially to use with a 110V power inverter too and camping gear, and it's easy to pull 30 amps + with those...

And the reason I thought about sharing this project today: the solar panel.

I have 2 of those, and I use them also to charge my electric bicycle batteries. I connect them to the battery through a solar panel controller that regulates the voltage so that I don't fry the batteries.

Why am I sharing this story today?

What happened is that I met Mike today, in the parking lot of a commercial shopping center, in Winston Salem, North Carolina. He builds electric vehicles. This one is a chEVrolet :)

144V was true some months back, he now runs a bit higher voltage using Lithium batteries with a bunch of BMS (battery monitors). He swapped the previous battery pack out (over 1000lbs, 18 batteries at 8V each, lead acid) but didn't repaint the truck :)

There is quite a bit more information on his truck here at: Backyard Green. So we talked a good bit about the tech, and even got into the subject of solar power, and I mentioned I powered one of my raspberry pi through solar power. I thought that maybe others would be interested in this aspect, the "green computing" side of the pi...

Anyway, back to Mike, he does a good bit of work with microcontrollers and he had a pi lookalike embedded in the console of his electric truck and he's thinking of building his own graphical interface. Sounds like a perfect match for the Raspberry Pi and Python... At any rate, it was a really interesting discussion.

Friday, September 14, 2012

Sidekick 2

Continuing on using the raspberry pi as your desktop's sidekick, we will focus today on making it easier to work with, better integrated, when your desktop is Unix (Solaris, OpenIndiana), Linux, Mac OS/X or even Windows (except you wont be able to use ssh-keygen or scp - instead check the section I Got a PC? toward the end of the post).

Automating login

First thing first, we need to create a new user on the Raspberry Pi. Although the user pi is pretty cool, you dont want to have to specify the user in all the commands you will do, so we'll match it to the username on the desktop.

Let's say your username is user on your desktop (of course, if you want to have a username billybob, then replace user with billybob in the below code). You will need to connect as the pi user, then set up a new user:

 ssh pi@raspberrypi  
 (enter your pi user password)  
 pi@raspberrypi ~ $ sudo useradd -d /home/user -s /bin/bash user   
 pi@raspberrypi ~ $ sudo mkdir /home/user  
 pi@raspberrypi ~ $ sudo chown user:pi /home/user  
 pi@raspberrypi ~ $ sudo passwd user  
 pi@raspberrypi ~ $ Enter new UNIX password:  (type password)
 pi@raspberrypi ~ $ Retype new UNIX password:  (type it again)
 pi@raspberrypi ~ $ passwd: password updated successfully  
 pi@raspberrypi ~ $ sudo cp .bashrc ../user
 pi@raspberrypi ~ $ sudo cp .profile ../user

The last item we have to do is to edit the /etc/sudoers file and add our user to it ([esc] means hit the escape key):

 pi@raspberrypi ~ $ sudo vi /etc/sudoers  
 (add the following line after going to last line and typing o)  
 [esc] :wq!
 pi@raspberrypi ~ $ exit

BTW, for most people, there is too much detail (such as how to add a line in vi), but keeping in mind that there are some people in schools reading this and they just starting playing with this, I think it is well justified).

 We now go back to our desktop and test that we can login as the user (no need to specify user@raspberrypi, just raspberrypi since the default is to user the desktop current user):

 user@desktop ~ $ ssh raspberrypi  
 (enter password)  
 user@raspberrypi ~ $ mkdir .ssh  
 user@raspberrypi ~ $ exit  

Now, we will generate an RSA private and public key pair. We will then copy the public key to the RPi as authorized_keys2 under the .ssh folder:

 user@desktop ~ $ ssh-keygen -t rsa  
 (enter to accept the defaults)  
 user@desktop ~ $ cd .ssh  
 user@desktop ~ $ scp raspberrypi:.ssh/authorized_keys2  
 (enter password)  

We will login once more on the RPi to change access:

 user@desktop ~ $ ssh raspberrypi  
 (enter password)  
 user@raspberrypi ~ $ cd .ssh  
 user@raspberrypi ~ $ chmod go-r authorized_keys2  
 user@raspberrypi ~ $ exit  

At last, we can now copy files using scp or login on our RPi without entering a password:

 user@desktop ~ $ ssh raspberrypi  
 user@raspberrypi ~ $  


SCP tasks

Getting a file

To get a file from the RPi, onto the desktop:

The file is in the /home/user directory:
user@desktop ~ $ scp raspberry:file.txt .
The file is in /home/user/directory:
user@desktop ~ $ scp raspberry:directory/file.txt .
The file is in /home/user/directory/subdirectory:
user@desktop ~ $ scp raspberry:/home/user/directory/subdirectory/file .

Putting a file

To get a file from the RPi, onto the desktop:

The file is in the /home/user directory:
user@desktop ~ $ scp raspberry:file.txt .
The file is in /home/user/directory:
user@desktop ~ $ scp raspberry:directory/file.txt .
The file is in /home/user/directory/subdirectory:
user@desktop ~ $ scp raspberry:/home/user/directory/subdirectory/file .

Action on a directory

To get or put a directory, simply use the -r flag:

user@desktop ~ $ scp -r mydir raspberry:
This will copy recursively mydir onto the server named raspberry, into the default home directory. There is a lot more flexibility to scp, so read up on it:

user@desktop ~ $ man scp

GUI access

I use OpenIndiana as a desktop, most of the time, and that OS, and most Linux versions, has a tool to connect to a server using various protocols and provide a GUI. In the case of OpenIndiana, it is the gnome tool that can be found in the menu as item "connect to server":

This will then open a Nautilus file browser:

Other Options

Another option under unix/linux to access files remotely is through sshfs, a FUSE module. It allows to mount an ssh (sftp) remote system as a local filesystem. If you need this, you are probably already know how to use it, so I wont get into details.

I got a mac?

There is no GUI option directly, Basically, using the technique above with FUSE, I've done it on my Mac using FUSE at, then I downloaded Macfusion.

If anybody wants a more detailed instruction, leave a comment. I dont want to spend too much time on this if no reader is using a raspberry pi as a sidekick to a Mac.

I got a PC?

To automatically login without password, you will need putty (see the previous blog entry on this) and also puttygen. But at the end of the day, why bother? 

The OS doesn't leverage this. Instead, get a GUI interface like Winscp to copy files back and forth.

I use winscp all the time with Windows 7, and you can save configurations, including passwords, so this is fairly painless.