Third party cookies may be stored when visiting this site. Please see the cookie information.

Running the Raspberry Pi headless with Debian Linux

The Raspberry Pi Linux computer is just as good as a headless computer as it is connected to a TV.

Whilst it's trivial to connect to a HDMI TV or even an analogue TV there are a number of questions from people trying to configure the Raspberry Pi in a headless mode without a monitor attached. I have already provided a tutorial to configuring the Raspberry Pi as a headless web server, but in that the initial configuration was done with the Pi connected to a TV / monitor. In this tutorial I am going to configure the Raspberry Pi without needing any kind of monitor attached.

The first thing to be aware is that it is far easier to perform the configuration with a monitor or TV attached, and in the case of a problem it's far easier to fix by being able to see the console messages. It's trivial to connect a TV to the Raspberry Pi and a monitor can be attached with a fairly inexpensive adapter cable.

This is based on the Debian Wheezy distribution. The earlier (Squeeze) distribution does not have ssh running by default and does not include the raspi-config tool. This should work with later versions. The Wheezy distribution is available from: Raspberry Pi blog (Wheezy Beta release).

Find the DHCP lease IP address

One option is to boot the Pi whilst connected to a network with a DHCP server (feature of most home network routers) and look at the DHCP lease information to get the IP address. To do this depends upon the specific router in question. On my Belkin Wireless router the option is called the DHCP client list which currently shows 12 entries one of which is obviously the Raspberry Pi. 	raspberrypi 	b8:27:eb:a3:9f:46

You could also try pinging IP addresses in the same subnet as another computer on the network until getting a response. For example if you have a laptop connected using dhcp and has an address of - try counting upwards
, .35, .36 - when you get one that replies to the pings then try
ssh pi@
Or using PuTTY etc. (replacing the address with the IP address that responded to the ping test.

Edit the SD card on a Linux computer

If these options are not possible then the following steps will configure the IP address manually before booting the Raspberry Pi.

First you need to choose an appropriate IP address and the gateway and DNS parameters. Seeguide for configuring an IP address manually on the Raspberry Pi.

To do this we need to make the changes directly on the SD card using another Linux computer. This can't be done within Windows (without purchasing additional software that can write to ext 4 formatted discs). If you are a Windows user and don't have a Linux computer handy then you can get download a Live CD or install Linux onto a USB disk and boot your computer directly from that (no changes need to be made to your computer hard disk). I configured this one using Xubuntu - see guide to choosing a Linux distribution. If you can figure out how to get into your bios to change the boot sequence then running a Linux Live desktop CD / USB image is fairly straight forward.

When in the Linux desktop insert the SD card with the Debian image into an SD card reader on the Linux computer. There should be two partitions that will normally mount automatically and perhaps provide a file browser window. The first small partition is the boot partition which we won't be touching here (this is the only one that can be seen if you mount the SD card in another operating system that doesn't recognise the Linux filesystem).

These instructions are based on using the command line from a shell prompt. It is possible to do this using a GUI only, but the instructions differ depending upon the distribution and installed packages.

It should be possible to see the partition name in the file browser, but if not then the mount command issued on a command shell will show all the partitions mounted.

On my computer the SD card mounted in /media/a6b2691a-99d8-472c-b8b6-1853656c2507

Change to the directory using
cd /media/a6b2691a-99d8-472c-b8b6-1853656c2507

The next two commands need to be run relative to that directory. Note that there is no '/' at the start of the path name. If you do include a '/' first then you will be editing the settings on the computer used to do the configuration and not the SD card.

To configure the IP address use:
sudo nano etc/network/interfaces

and change the file so that it contains:

auto lo

iface lo inet loopback

iface eth0 inet static




Using the appropriate addresses for address (Raspberry Pi IP address) and gateway (router IP address)

To set the DNS entry use:
sudo nano etc/resolv.conf
and enter the IP address of the router or your ISPs DNS servers.

Finally issue the sync command and unmount / safely remove the SD card

Boot the Raspberry Pi

The SD card should now be placed into the Raspberry Pi and it should boot into Debian with the IP address manually configured. If there is a problem then you can look at the logs by moving the SD card back to the Linux computer and looking in the var/log directory.

ssh to the Raspberry Pi

We have now completed the initial configuration for the Raspberry Pi. You can now connect from a computer running any operating system using ssh. Linux distributions all have a native command line ssh client installed by default, but Windows users will need to install a separate application such as PuTTY.

To connect using ssh enter
ssh pi@
at a command prompt (or enter the appropriate details into the GUI). This is asking to connect to ip address with the username pi.

You will be prompted whether to accept the key that the ssh server provides. This is a security feature that prevents someone else from putting a different computer pretending to be yours so as to steal you username and password information. Choose yes to save the key.

Note that if you reinstall the operating system then this will warn you that someone may be pretending to be the same computer. In the case that you've knowingly re-installed the operating system you can delete the ssh key using the instructions provided.

Enter the password and you will now get to the command prompt. There will also be a message:

NOTICE: this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'

pi@raspberrypi ~ $ 

You should now run the raspi-config as prompted to perform some initial configuration of the Raspberry Pi (if you had logged in directly on the Pi rather than through ssh then it would have launched the config tool automatically.

raspi-config Raspberry Pi configuration tool

The following things can be configured within the configuration tool:
expand_rootfs - required to allow you to use all the space on your SD card if it is bigger than 2GB. Or you could manually partition if you prefer, but that is a more advanced topic.
overscan - not required that relates to using a TV / monitor
change_pass - it is very important that you change the password as the password is otherwise at the default.
configure_keyboard - not required as we don't have a keyboard physically connected.
change_locale - required if not in the UK
change_timezone - choose appropriate time zone, otherwise UTC (GMT) is used. Note that the Raspberry Pi does not include a realtime clock, but it will use the network time protocol to get the time from the Internet if available.
memory_split - this allows you to change the amount of memory available for the video and main system. Without a TV / monitor connected then you should set to "224MiB for Arm, 32MiB for VideoCore".
ssh - leave enabled
finish - choose the finish option to quit and not show the "not fully configured" message in future. You can always run the configuration tool again by using sudo raspi-config.

Finally reboot so that the configuration changes are all applied.
sudo reboot

GUI access

So far we have setup ssh which provides a command line for communicating with the Raspberry Pi and can be used for transfering files (scp and sftp). If you require GUI access then we need to look at a remote access application such as VNC - see next tutorial.

Previous TCP/UDP port numbers (/etc/services)
TCP/UDP port numbers (/etc/services)
Next Remote GUI access to a Linux computer using Tightvnc
Remote GUI access to a Linux computer using Tightvnc