Raspberry Pi Server General Configuration

Changing Password

The default Raspberry Pi OS user is named pi, and the default password is raspberry. Any responsible person will at least change the password. That can be done with the passwd command.

The passwd command followed by no arguments will change the password of the current user account. The account whose password is to be changed can also be specified, but that requires root privilege.

pi@raspberrypi:~$ passwd
Changing password for pi
Current password:

The user will then be prompted for his or her current password, which is raspberry in this case. However, if he or she has root privilege (is the root user or uses sudo) no password is needed.

pi@raspberrypi:~$ passwd
Changing password for pi
Current password:
New password:
Retype new password:
passwd: password updated successfully

Then the user will be prompted to enter a new password and then confirm it by entering it again. If that is done successfully, the new password will be in place.

Changing User Account

As mentioned in the section above, the default user password should always be changed. Optionally, the default user account itself can also be changed. Although this is not necessary, a means of doing so is documented here.

The adduser command can be used to create a new user account. It must be run with root privilege and can be passed the name of the new account that is to be created. The command shown below creates a new account call my-new-account.

pi@raspberrypi:~$ sudo adduser my-new-account
Adding user `my-new-account' ...
Adding new group `my-new-account' (1001) ...
Adding new user `my-new-account' (1001) with group `my-new-account' ...
Creating home directory `/home/my-new-account' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
    Full Name []: Various And Sundry
    Room Number []: 27
    Work Phone []: 1-800-ITS-UNIX
    Home Phone []: 1-800-MYHOUSE
    Other []:
Is the information correct? [Y/n] Y

Once a new user has been created, it should be added to all of the groups that the user pi was a part of. That can be done by editing the file /etc/group. Editing this file requires root privilege. Assuming that the user pi will be deleted, we can modify each line that ends with pi by replacing pi with the name of our new user. Below is a before and after table in which pi is replaced with an account called my-new-account.

Before

After

root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:pir
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:pi
fax:x:21:
voice:x:22:
cdrom:x:24:pi
floppy:x:25:
tape:x:26:
sudo:x:27:pi
audio:x:29:pi
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:pi
sasl:x:45:
plugdev:x:46:pi
staff:x:50:
games:x:60:pi
users:x:100:pi
nogroup:x:65534:
systemd-journal:x:101:
systemd-timesync:x:102:
systemd-network:x:103:
systemd-resolve:x:104:
input:x:105:pi
kvm:x:106:
render:x:107:
crontab:x:108:
netdev:x:109:pi
messagebus:x:110:
ssh:x:111:
bluetooth:x:112:
avahi:x:113:
spi:x:999:pi
i2c:x:998:pi
gpio:x:997:pi
systemd-coredump:x:996:
pi:x:1000:
my-new-account:x:1001:

root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:my-new-account
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:my-new-account
fax:x:21:
voice:x:22:
cdrom:x:24:my-new-account
floppy:x:25:
tape:x:26:
sudo:x:27:my-new-account
audio:x:29:my-new-account
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:my-new-account
sasl:x:45:
plugdev:x:46:my-new-account
staff:x:50:
games:x:60:my-new-account
users:x:100:my-new-account
nogroup:x:65534:
systemd-journal:x:101:
systemd-timesync:x:102:
systemd-network:x:103:
systemd-resolve:x:104:
input:x:105:my-new-account
kvm:x:106:
render:x:107:
crontab:x:108:
netdev:x:109:my-new-account
messagebus:x:110:
ssh:x:111:
bluetooth:x:112:
avahi:x:113:
spi:x:999:my-new-account
i2c:x:998:my-new-account
gpio:x:997:my-new-account
systemd-coredump:x:996:
pi:x:1000:
my-new-account:x:1001:

Then log into the new account and delete the old account. The commands needed to do this are shown below.

pi@raspberrypi:~$ sudo su my-new-user

my-new-user@raspberrypi:~$ sudo userdel pi

Updating the System

Finally, we shall update the system.

We will run sudo apt-get update to update the local list of available packages.

We can also run sudo apt-get upgrade to update all of the installed packages. This is not necessary, and it can take quite a while and use a reasonable amount of disk space, depending on how old the operating system is. I often omit this step, but I am using a reasonably up-to-date version of Raspberry Pi OS, so I ran it this time.

my-new-user@raspberrypi:~$ sudo apt-get update
Lots of output that I will not put in this web page.
my-new-user@raspberrypi:~$ sudo apt-get upgrade
Lots and lots of output that I will not put in this web page.

Now I consider the Pi to be configured. The next article will discuss installing the Apache Web Server, something actually related to web development.


Previous Published December 16, 2020 Next