Customizing Raspbian

Welcome back!

This blog post will be about customizing the Raspbian operating system that was freshly installed before. Customization comes in different flavours. I will only do the basics here, so your RPi is protected from „the outside“ world. This is just because everybody knows the username and password of the RPi and can hijack or hack your device.

And again: I am using a Raspbian image. I know that the following works for this distribution. I cannot tell you if it works for any other image that is not Debian based. As I lost my monitor for configuring the RPi, I will do a short intro into SSH’ing into your device.

SSH to your RPi

Go to and download the Windows Installer or the Putty.exe file. The installer bundles everything PuTTY has to offer (and I really like that Pageant and PuTTYgen are in that bundle, as I do use both as well).

Install the Windows Installer or start the Putty.exe.

Find the IP of your RPi. Either look it up in you router’s configuration or mark it down when having a monitor connected to your RPi. When you type the following command, you can find it:
sudo ip addr show

The upper command shows an output like this:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff
inet brd scope global eth0
valid_lft forever preferred_lft forever

The inet tells you the IP address that you need to put into PuTTY:

2015-08-20 19_49_56-PuTTY Configuration

When you connect to the RPi for the first time it asks you if the key is correct. Say „Yes“:

2015-08-20 20_00_49-PuTTY Security Alert

Now a console window shows up. Log into your RPi with the following credentials:
login: pi
password: raspberry

It might take some time and then you will see something like this:

2015-08-20 20_02_21-pi@raspberrypi_ ~

You can work with this console the same way you work with the terminal and a monitor. 😉

Change username

Add substitute user

I do add a substitution user which I will use for the process and delete afterwards. This user only needs a name, nothing more. I will call him substitute.

sudo adduser --no-create-home substitute

You need to enter a passwort. Don’t take something too hard as this user will only last for a couple of minutes. Your console will look something like this. [Stuff written in [ ] brackets are user made entries.]

Adding user substitute' ...
Adding new group
substitute' (1002) ...
Adding new user substitute' (1001) with group substitute' ...
Not creating home directory /home/substitute'.
Enter new UNIX password: [write some password here]
Retype new UNIX password: [retype password]
passwd: password updated successfully
Changing the user information for substitute
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]

Give substitute user admin rights

Now open the sudoers file: sudo visudo.

At the end of the file write the following: substitute ALL=(ALL) NOPASSWD: ALL

Close the file with Strg + X (Ctrl + X) , then type Y and hit Enter.

Log out of your user

Type logout. When using PuTTY, you need to start the tool anew, as the logout call closes the console window.

Log into your substitute user with:
login: substitute
password: [the password you have chosen]

Rename your initial RPi user

How would you like your user to be named? I like mine to be named "piwolf" so I will show you how to do this.
After you logged in with your substitute user, you need to type the following:

sudo usermod --move-home --login [piwolf] --home /home/[piwolf] pi

Rename user in groups

Now change the username in the linux groups with this command:

sudo groupmod -n [piwolf] pi

Revoke substitute's user admin rights

Now back to the sudoers file. Type in console and go to the end of the file:

sudo visudo

Remove those lines:

substitute ALL=(ALL) NOPASSWD: ALL

Add this line:


Close the file with Strg + X (Ctrl + X) , then type Y and hit Enter.

Log out of your user

Type logout. When using PuTTY, you need to start the tool anew, as the logout call closes the console window.

Hint: Yes, the password is the old password of the pi user!

Log into your final user with:
login: [piwolf]
password: raspberry

Delete substitute user

Delete the user like this:

sudo deluser substitute

You console will tell you something like this:

Removing user substitute' ...
Warning: group `substitute' has no more members.

Remove pi user from raspi-config

You need to rename the user like this. Open the raspi-config file in your console like this:

sudo nano /usr/bin/raspi-config

You can search in the file via Strg + W (Ctrl + W).
Look for

if id -u pi > /dev/null 2>&1; then

and rename pi with your new username:

if id -u [piwolf] > /dev/null 2>&1; then

Look for

sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi/"

and rename pi with your new username:

sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=[piwolf]/"

Look for

passwd pi

and rename pi with your new username:

passwd [piwolf]

Close the file with Strg + X (Ctrl + X) , then type Y and hit Enter.

Last setup of raspi-config

Start raspi-config with sudo raspi-config.

In the overview screen choose Enable Boot to Desktop / Scratch. Hit Enter.

Choose Desktop Log in as user ‘pi’ at the graphical desktop. Hit Enter.

You are back in the overview screen.

In the overview screen choose Enable Boot to Desktop / Scratch. Hit Enter.

Choose Console Text console, requiring login (default) . Hit Enter.

I changed the boot option back to console as I want to install the Plex server laters. This is not possible in a graphical user interface.

Tab to the Finish button. Hit Enter.

When asked Would you like to reboot now? hit Enter on the Yes button.

Your RPi now has a new username.

Change password

A new username is a nice thing. But with the old raspberry password, it is still pretty useless. After your RPi has restarted, log in with your credentials:

login: [piwolf]
password: raspberry

Type passwd and give yourself a new password. Your console will look like this:

Changing password for [piwolf].
(current) UNIX password: raspberry
Enter new UNIX password: [your new password]
Retype new UNIX password: [retype your new password]
passwd: password updated successfully

You can also give a SSH key instead of a password. I will not cover this, but there is a good (german only) ressource located here:

Change name or device

Change hosts

You might have more than one RPi in your network. And they are all named raspberrypi:

2015-08-20 20_49_49-.__ Willkommen beim Web-basierenden Konfigurator__.

Maybe you want one as a weatherstation or a jukebox or something else. It might make sense to change the name of the RPi now, as I already know that I want it to be a Plex server.

At a terminal type

sudo nano /etc/hosts

Your hosts file will look like this: localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters raspberrypi

Replace raspberrypi with the name your RPi should get. I will call mine plexwolf.

Close the file with Strg + X (Ctrl + X) , then type Y and hit Enter.

Change hostname

Now type
sudo nano /etc/hostname
and change raspberrypi to the same name you used in the hosts file.

Close the file with Strg + X (Ctrl + X) , then type Y and hit Enter.

Tell the system and reboot

You have to tell the system that something happened. You do this with:

sudo /etc/init.d/

My terminal always tells me sudo: unable to resolve host raspberrypi but that is okay. I always do the upper shell command twice. 😉

After this you need to reboot the system for the changes to take place:

sudo reboot

When the RPi is back up and running, you can see the new device name in your router:

2015-08-20 20_59_24-.__ Willkommen beim Web-basierenden Konfigurator__.

Give the RPi a static IP

I want the RPi to have a static address. Why? Because it makes remembering the Plex webpage url easier later on. 😉

Getting the gateway and subnet addresses

When you have the utlimate power over your network, you will aready know the gateway and subnet address. When you do not know them, you just log into your RPi console and can get them via this command:

netstat -r -n

Your console will look somewhat like this. You can look up the gateway and the subnet mask as you can see here:

2015-08-20 21_16_54-piwolf@plexwolf_ ~

Setting up the static stuff

Now let us add a static ip adress in the interfaces file. I love mine to have the 42 as the last number. So I will use for my network (yeah, totally nerdy, eh!). Open the interfaces file in the console with this command:

sudo nano /etc/network/interfaces

In this file find the line saying iface eth0 inet dhcp and change it to:

iface eth0 inet static
address []
netmask []
gateway []

Close the file with Strg + X (Ctrl + X) , then type Y and hit Enter.

Restarting the net

You need to restart the network service to get the new setting up and running:

sudo /etc/init.d/networking restart

After running this command you will most surely get this warning: Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces.
If you want a nice explanation, look here:

When you are SSH’ed on your RPi via PuTTY, your PuTTY will loose connection. You need to reconnect with the NEW ip address you gave your RPi before. 😉

That’s all folks

That’s all for today. Next time I will talk about mounting usb harddisks and samba shares, maybe some overclocking and the heart of my RPi 2: the Plex server. 🙂

petra Verfasst von:

Ein Kommentar

  1. 29. August 2015

    ….. but why go through all the hassle to rename that user? Why not delete & create a new one? And dont do networking restart, do ifdown/ifup please.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.