The default configuration for Raspbian on the Raspberry Pi is completely functional and allows you to jump straight in and start using your Pi from the command line or from the desktop. However, it is often desirable to move beyond the defaults. The first default you should probably change is the default password for the user “pi.” In a relaxed home environment, using the default password isn’t likely to cause much problem. However, if your Pi is in any way exposed to the Internet or used in a more public place, then changing the password is essential.
To change the password for the default user, log in using “pi” (username) and “raspberry” (password), and then type the following at the command line:
You will then be prompted for the current password (i.e. “raspberry”), and you will be asked to enter a new password. It is important to pick a good password, and using a common word isn’t recommended. You should avoid passwords like: 123456, password, qwerty, abc123, iloveyou, 111111, letmein, monkey, 123123 and princess. A strong password should use a mixture of uppercase and lowercase letters and include numbers and symbols. Alternatively, you can use a long sentences as mentioned here. Once you have entered the new password, you will need to enter it again as a confirmation.
If you have more than one person using the Raspberry Pi, then you can add additional users. This will give each user their own login credentials with their own home directory, etc. To add a new user use:
sudo adduser newuser
“newuser” will be the name of the user you want to add (e.g.
sudo adduser gary).
You will be asked to enter the password for the new user (twice) and optionally enter some account information like the user’s full name, etc. If you want to give the new user permission to run system commands using
sudo, then you need to edit the “/etc/sudoers” file. Type the following:
Move to the bottom of the file and add this line:
newuser ALL=(ALL) NOPASSWD: ALL
Where “newuser” is the username of the user previously added via
adduser. Exit nano using “Ctrl + x”.
If you want to change the password of a user (because they have forgotten it or you want to block their access to the account), then use the
passwd command but with the username as the first parameter:
sudo passwd gary
The default name for your Raspberry Pi is “raspberrypi”. You can see it using:
Renaming your Pi requires two steps – first the “/etc/hostname” file needs to be changed, and then the “/etc/hosts” file needs to be edited. The first of these two files is used to set the hostname during boot-up. The second file lists the known hosts on the network and includes the local Raspberry Pi but under its default name.
Edit “/etc/hostname” as follows:
sudo nano /etc/hostname
Replace the word “raspberrypi” with the new name, e.g. “garypi” and exit nano with “Ctrl + x”.
To edit the “/etc/hosts” file, type:
sudo nano /etc/hosts
Find the line that reads:
And change the word “raspberrypi” to the new name, e.g. “garypi” and exit nano with “Ctrl + x”.
Reboot your Pi with “
sudo reboot” and check the name using the “
Other things you might consider doing include setting up Wi-Fi on your Pi and configuring a static IP address. If you have any questions about administering user accounts and altering the machine’s hostname, feel free to ask in the comments below.