My Raspberry Pi arrived. Here's how I started using it.

Posts Tagged: software

How to Safely Shutdown or Reboot Your Raspberry Pi

Title says it all, but there’s a bit more useful information too. Personally, I’ve always used “sudo halt”.

Text

This post will only interest you if you’re using a Mac. AFP (Apple Filing Protocol) is the protocol Macs use to share files over a network. This post will guide you through setting this up using Netatalk. It will also cover setting it up to be easily accessible without the IP address.

To install Netatalk, simply use apt-get:

  • sudo apt-get install netatalk

You should now be able to access your Raspberry Pi from the Finder side bar and under Network (shift + command + k).

Finder sidebar - Shared

EDIT: The remainder of this post is now outdated and should not be required once you have installed netatalk.

This installs 2.1.2 of Netatalk which is not the latest (2.2.3 at time of writing) which may cause issues with using this for Time Machine and with Lion, although I have not experienced any issues on my two Lion machines. My attempts at installing 2.2.3 failed though I’m sure it’s possible.

When apt-get has finished, you can connect from the Mac:

  1. In Finder, open the Go menu and select “Connect to Server…” (⌘K).
  2. Enter “afp://” followed by your Raspberry Pi’s IP address.
  3. Enter your Raspberry Pi’s username and password (default username is “pi” with password “raspberry”).
Connect to server dialog
Now wouldn’t it be nice if the Mac showed your Pi under the shared section of the Finder sidebar? For this the Raspberry Pi needs to be advertising itself on the network, Apple’s Zero Configuration protocol for this is called Bonjour. This is supported under Netatalk 2.2.3 but not in the version we’ve installed. Avahi can do this for us, but requires a bit more work (below steps have be adapted from this article by Sam Davis):
  1. First run “sudo apt-get install avahi-daemon”.
  2. Next, make sure it runs at startup, enter “sudo update-rc.d avahi-daemon defaults”.
  3. Create a configuration file containing information about the server. Run “sudo nano /etc/avahi/services/afpd.service”. Enter (or copy/paste) the following:
    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
       <name replace-wildcards="yes">%h</name>
       <service>
          <type>_afpovertcp._tcp</type>
          <port>548</port>
       </service>
    </service-group>

    Press ctrl and x to exit, then press y to to save changes and return after confirming the location.
  4. Restart Avahi: “sudo /etc/init.d/avahi-daemon restart

The Debian package management tools

Useful information on how to use apt-get.

Text

The RPi version of Debian comes with the Midori web browser, but you might want something a bit more mainstream, so try why not Chromium.

To install simply run “sudo apt-get install chromium-browser” from the command line and it will appear under Internet in the Application menu (icon in the bottom left corner).

Source: elinux.org

Text

So you’ve got your Raspberry Pi setup, but what if you don’t have a dedicated monitor to use with it (for example, mine’s connected to my TV). How can you use it without disrupting your setup? VNC (Virtual Network Computing) allows you to see your Pi’s desktop and control it remotely using another computer running Mac OS X, Windows or Linux (and other devices too).

The VNC server software runs on your RPi, access it by running VNC client software on your other device.

The VNC Server

There are various guides for this online, most suggest using the TightVNC server software, here’s my summarised need to know version, run all commands from the command line:

  1. Install tight VNC: “sudo apt-get install tightvncserver”
  2. Run the program: “tightvncserver”
  3. Start a VNC session: “vncserver :1 -geometry 1024x728 -depth 24”

Notes:

  • Configure the session’s resolution after the -geometry argument. In the above 1024x768 is used. The RPi is capable of full HD so you could try 1920x1080.
  • Colour depth is specified by the -depth argument. In the above exampe, 24-bit colour depth is used. You could use 16-bit instead to reduce network traffic.
  • You can start more than one VNC session by running subsequent vncserver commands, just increment the first digit: e.g “vncserver :2 …” for a second, ”vncserver :3 …” for a third (I don’t know how many the RPi could handle).
  • You can set this to run at start up, see the eLinux wiki tutorial, or look for a later post on this blog on automatic login which can start the VNC session with less effort.

The VNC Viewer/Client

There are lots of VNC clients you can use, depending on your platform. I’m using Apple’s Remote Desktop software which is incredibly powerful (especially when administering Macs) but is overkill if you are just using it with your RPi. TightVNC has a free client application, there’s a native Windows version and a surprisingly good (but limited) Java version, which should run on any desktop/laptop system. A Google search should find you a suitable app for your own system.

To connect to your RPi:

  1. Get your RPi’s IP address by running “ip addr show”. The IP address with be shown as highlighted in the image below.
  2. Connect your client to the IP address obtained from 1. 
  3. Use port “590x”, where “x” is the session number used in step 3 in the previous section. If this doesn’t work, enter the IP address followed by “:x”, e.g. “192.168.1.50:1”.

ip addr show command example