Raspberry pi – Beginners setup

Setting up the raspberry pi:

Make sure the SD card is inserted and the Pi is connected to a HDMI screen and be sure you have the ethernet cable connected to the device.

Now connect the micro-USB power supply.

If you try to work with a NON-powered USB hub connect only the keyboard. If you need to use the mouse too, try to connect it to the USB hub and let free one USB port to make sure you have space for another device like a USB wifi link.

When the raspberry pi has start and asks you for the username and the password, if the keyboard writes characters without pushing any button, disconnect the keyboard and plug in to another USB port of the hub.This in theory will solve the problem.

CAUTION: If you connect any item to a USB port during the start up the raspberry pi will reboot.

This is caused because of the raspberry pi has a 5V power supply and each of the devices like keyboards and mouses you will connect needs a 5V supply for each one.

Another solution is to buy a USB powered hub like the one on the next link that is made for the raspberry pi specifically:

http://www.raspberrypi.org/archives/4803

And there is the commertial video: http://www.youtube.com/watch?v=s6ORM4xW6E0

The default username and password are:

Username: pi
Password: raspberry

When you hit the command prompt enter the following to launch the desktop:

startx

Changing the password of the raspberry pi:

You just have to type:

passwd

And the prompt will ask for the old password first and then to enter the new password you want and to repeat it for checking if you write it correctly:

pi@raspberrypi ~$ passwd
Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Adding a new user to the raspberry pi:

To add a newuser to the raspbian system:

sudo adduser username

the output is the next one:

pi@raspberrypi ~ $ sudo adduser username
Adding user `username’ …
Adding new group `username’ (1003) …
Adding new user `username’ (1002) with group `username’ …
Creating home directory `/home/username’ …
Copying files from `/etc/skel’ …
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y

The system will create a new user with the name: “username” and then will create a home directory and all the things necessary for any user.
The user information can be entered as the default, so you only have to press the Enter button and hit “y” to the final prompt and the user will be created.

Then if you want to check that the user was created and to know how many users are in your system type:

ls
cd /home/
ls

These commands will bring you to the home directory where all the users are placed, for example in my case there is the output:

pi@raspberrypi / $ ls
bin dev home lost+found mnt proc run selinux sys usr
boot etc lib media opt root sbin srv tmp var
pi@raspberrypi / $ cd home
pi@raspberrypi /home $ ls
pi user username

And finally to change the password for root user, to enter with a password:

sudo passwd root

pi@raspberrypi /home $ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Updating the Debian Raspbian “wheezy” Linux Distribution:

Before you begin to install any software the first you have to do is to update the image version and all the packages of the distribution. Make sure you have an internet connection and run the following command. It may take a few minutes.

sudo apt-get update

Followed by:

sudo apt-get upgrade

This command may take 1 – 2 hours, so you can go to take a “relaxing cup of cafè con leche”. To don’t get bored I recommend this surprising video:

http://www.youtube.com/watch?v=hsjYVtRLuPI

Again make sure you have an internet connection and run:

sudo apt-get dist-upgrade

You can run these commands every now and again to make sure you have the latest software. If you’re asked to confirm anything, just hit ‘y’ on the keyboard.

The Raspberry Pi Config Tool:

The Raspberry Pi Configuration Tool is a very useful tool pre-packaged with the Raspbian “wheezy” distribution. You’ll probably see it during installation; but you can launch it manually for the terminal with the following command:

sudo raspi-config

Raspi-config

I recommend you to run the following commands as soon as possible:

  • expand_rootfs: This will expand the file system to the full size of your SD card; allowing you to use the full capacity for programs, etc.
  • change_pass: Change the default password!
  • change_locale: Change your location. This will be used by some 3rd party installer to install the correct config for your setup.
  • change_timezone: Change the timezone so, well, so you have the right time.
  • configure_keyboard: To set the keyboard as the button distribution of your country. By default there is the english keyboard but it can be changed with this tool.
  • ssh: To enable remote access and enter the raspberry pi without using a screen, the keyboard, the mouse, etc.

After performing all this steps you only have to download “putty”, a SSH or telnet client, on Windows to enter in remote access with your computer to the raspberry pi.

There is the link to download putty: http://www.putty.org/ or

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

In a linux distribution you don’t need putty, just enter the following command to the terminal:

ssh -X <ip address of Rpi> -l <username on Rpi>

Then enter the password of your raspberry pi and that’s all you have to do.

Locale settings:

By configuring the locale settings, you can change the language and country settings for much of the software available for the RPi. The default RPi locale is English/Great Britain (“en_GB”).

You can change this with the enxt command:

   sudo dpkg-reconfigure locales

You will get a very long list of possible locales. You can enable/disable a locale by pressing the spacebar (not Enter), and scroll through the list using the arrow keys.

Selecting “All locales” will generate all possible locales, taking a very long time and using a great deal of space. Select only those you wish to use.

If you’re unsure of which locale to pick, look up a two-letter language code and a two-letter country code on Wikipedia, and see if you can find a matching locale.

When you’re done chosing locale, press Enter.

Keyboard layout:

If different letters appear on-screen from that which you typed, you need to reconfigure you keyboard settings. In Debian, from a command line type:

sudo dpkg-reconfigure keyboard-configuration

Follow the prompts.

Or: From the command line type:

sudo nano /etc/default/keyboard

Then find where it says

XKBLAYOUT="gb"

and change the gb to the two-letter code for your country.

You may need to reboot the raspberry pi to update the changes.

If you wish more additional information about the raspberry pi configuration and about the characteristics of the raspberry pi check out this link: http://elinux.org/R-Pi_Troubleshooting#Re-mapping_the_keyboard_with_Debian_Squeeze

This is a really nice web page to get started on the raspberry pi.

More interesting links are: http://elinux.org/RPi_Beginners

http://www.youtube.com/watch?v=SmMMKojOE4U

http://fos.cmb.ac.lk/esl/raspberry-pi-initialising-setup/ (a very complete web page to get started with the rapsberry pi, view this page if something in this tutorial is not enough clear).

Installing VNC on the Raspberry Pi for Remote Access:

You may find it a bit cumbersome having a keyboard and mouse connected to the Raspberry Pi. What’s the point in having a computer smaller than your TV remote if you need to connect a massive Keyboard? And probably isn’t a confortable way to manage your raspberry pi.

Installing VNC will allow for remote access via a laptop, home PC or any other computer; while the Pi remains hidden away behind the TV or next to the router.
Giving the Pi a Static IP Address:
To know where the Pi is, let’s give it a static IP address. If you aren’t sure what your local network range is, open a command prompt from a Windows PC.

Start > Run and enter:

cmd

Now type:

ipconfig

You should see something like:

IPv4 Address. . . . . . . . . . . : 192.168.1.14
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1

We give the Pi the same details excluding the last 3 digits of the IPv4 Address. Let’s make it easy to remember:

Type the next command to know which is the IP adress of the raspberry pi:

ifconfig
192.168.1.11

Back in the Raspberry Pi go to the command prompt again, don’t start the desktop.

Type:

sudo nano /etc/network/interfaces

This will show the network interface configuration file in the nano text editor. I recommend the nano text editor to modify any file and to treat them because is a really powerful text editor.

The word “sudo” simply runs this command with super user privileges. If you have entered the raspberry pi like a super user, you can enter the command without this word.

You can save yourself a lot of time at the Linux command prompt by using “Tab” to auto complete. This “treak” completes the rest of a command that you have used other times, it seems like is only an additional tool but it saves a lot of time when you manage large commands and you don’t remember exactly the way to type them.

Another useful “treak” is to type “CTRL + R” to open a search prompt where you can type a part of a command and the prompt shows all the previous commands that you have entered with and specific word or words.

Going back to the file we have just opened. You should see:

iface lo inet loopback
iface eth0 inet dhcp

Change this to (your IP details maybe different depending what you got from ifconfig):

iface lo inet loopback
iface eth0 inet static
address 192.168.1.11
netmask 255.255.255.0
gateway 192.168.1.1

Use Ctrl X to exit. Hit “yes” when prompted to save.

Then you have to setup the DNS servers which are in a different file:

sudo nano /etc/resolv.conf
nameserver 8.8.4.4
nameserver 8.8.8.8

Change the DNS servers by the ones you have.

Use “Ctrl X” again to exit. Hit “yes” when prompted to save.

Now restart the network interface to apply changes without a reboot:

sudo /etc/init.d/networking stop

Followed by:

sudo /etc/init.d/networking start

Now your Raspberry Pi will always have the same IP address. Try pinging it from the Windows command Prompt:

ping 192.168.1.11

Installing VNC on the Pi:

We’re going to use Tight VNC here (server on the Raspberry Pi and Viewer on Windows).

If you have UBUNTU or some other distribution of linux in your laptop or home computer, you will have to install Tight VNC but the Viewer part on the Linux.

There’s an excellent tutorial over at Penguin Tutor if you need more information.

First of all install the Tight VNC Server from the command prompt:

sudo apt-get install tightvncserver

Let it finish installing (if you’re asked to confirm anything, just hit ‘y’ on the keyboard). When complete start the server:

vncserver

You’ll be asked to create a password, enter one and confirm. I used “raspberr” for ease of use because the password will be truncated to 8 characters.

There is no need to create a view only password, unless you have a specific need.

When the server starts it will tell you which virtual desktop has been setup. Every time you start VNC you’ll see something like:

New 'X' desktop is raspberrypi:1

Note the :1. This is the desktop session created. You can add more by running VNC again.

These says that it’s virtual desktop 1. You would connect to this using :1 at the end of the IP address in the client.

You can run multiple instances. Each time you start tightvncserver it will use the next available desktop, but in most cases you will just need one.

There are other tutorials that use TightVNC as a client for the Windows computer but in my case I have used an additional application of the google chrome browser that does the same with only the download of another option that is implented in the browser.

The next link explains how to use it and download it: https://chrome.google.com/webstore/detail/vnc-viewer-for-google-chr/iabmpiboiopbgfabjmgeedhcmjenhbla/related

VNC viewer application of google chrome browser

VNC viewer application of google chrome browser

I you don’t have google chrome installed you can download it here:

http://www.google.es/intl/es/chrome/

The advantatge of this VNC viewer is that it works in Windows, in linux and in Mac OS distrbutions.

When you have the application installed, the only thing you have to do is to login with the IP adress of your raspberry pi and enter the password you have chosen with the TightVNCserver installation in the raspberry pi.

VNC viewer initial page

VNC viewer initial page

After this initial page it will ask you for the password.

If you prefer TightVNC for the viewer (talking about Windows), this is the link to download it but I find easier the previous one: http://www.tightvnc.com/

But in linux distributions you don’t have to download it, instead of this, you can follow the next steps.

On a Linux computer you can install the viewer with:

sudo apt-get install xtightvncviewer

or if that is not in the repositories try:

sudo apt-get install ssvnc

This will work with Debian / Ubuntu based distributions only, for other distributions use the synaptic package manager.

To login use the next command:

xtightvncviewer 192.168.1.11:1

(replace with your own IP address as appropriate)

This is what you will see if everything runs in a correct way:

TightVNC viewer - Raspberry pi desktop

TightVNC viewer – Raspberry pi desktop

The link above of the penguin tutor shows how to start Xtightvncserver in the raspberry pi at start up but we haven’t had any need to do it. There are all the steps at the link if you prefer doing it.

TP-LINK configuration to enable wifi internet connection instead of ethernet:

The driver for the TP-Link TL-WN725N Nano USB Adapter doesn’t come with the Raspbian distribution by default, so it doesn’t work at the moment that we connect it to the raspberry pi USB Port.

Raspberry Pi Logo

There are 2 options to get it working:

1) Compiling the driver by yourself:

It may take a long time…

git clone https://github.com/liwei/rpi-rtl8188eu.git
git clone --depth 1 git://github.com/raspberrypi/linux.git rpi-linux
git clone --depth 1 git://github.com/raspberrypi/firmware.git rpi-firmware
cd rpi-linux
make mrproper
zcat /proc/config.gz > .config
make modules_prepare
cp ../rpi-firmware/extra/Module.symvers .
cd ../rpi-rtl8188eu
CONFIG_RTL8188EU=m make -C ../rpi-linux M=`pwd`
sudo rmmod 8188eu
sudo install -p -m 644 8188eu.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless
sudo depmod -a
sudo modprobe 8188eu

2) Download a precompiled version of the driver:

You can download a compiled version and get the driver installed without spending such a long time as the first option:

wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20130209.tar.gz
tar -zxvf 8188eu-20130209.tar.gz
sudo install -p -m 644 8188eu.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless
sudo depmod -a
sudo modprobe 8188eu

There is another version here, to get sure that the version in dropbox doesn’t disappear: http://file.zhujunsan.net/8188eu.ko

Once we have finished one of the two options, you have to use the Wifi Config (wpa_gui) application to configure the wifi net. This application is in the desktop of the raspberry pi so you have to use the VNC viewer or access the raspberry pi with the screen, the keyboard and the mouse.

This application configures automatically the file /etc/wpa_supplicant/wpa_supplicant.conf. There is the content of this file once we have run the application to configure the wifi:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
       ssid="WLAN"
       psk="XXXXXXXXXXXX"
       proto=RSN
       key_mgmt=WPA-PSK
       pairwise=CCMP
       auth_alg=OPEN
}

obviously this configuration will change of my configuration. “ssid” represents the name of the net and “psk” the password of the net.

And finally I had to configure the DNS servers to solve internet names. It can be done editing the file /etc/resolv.conf. You only have to add your DNS servers (normally the supplier gives you this information) or you can use 8.8.4.4 and 8.8.8.8 (DNS servers of Google):

nameserver 8.8.4.4
nameserver 8.8.8.8

Commands to control the raspberry pi:

Shutdown your Pi in 1 minute:

sudo shutdown -h 1

Shutdown your Pi now:

sudo shutdown -h now

Reboot your pi in 1 minute:

sudo shutdown -r 1

Reboot your pi now:

sudo shutdown -r now

sudo reboot

Get manual for any command:

man [command]

For example:

man shutdown
Advertisements

Un pensament sobre “Raspberry pi – Beginners setup

  1. Retroenllaç: dump1090 – installation | Build your own ADS-B aeronautical radar with low-cost equipment

Deixa un comentari

Fill in your details below or click an icon to log in:

WordPress.com Logo

Esteu comentant fent servir el compte WordPress.com. Log Out / Canvia )

Twitter picture

Esteu comentant fent servir el compte Twitter. Log Out / Canvia )

Facebook photo

Esteu comentant fent servir el compte Facebook. Log Out / Canvia )

Google+ photo

Esteu comentant fent servir el compte Google+. Log Out / Canvia )

Connecting to %s