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 |
---|---|
|
|
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 |
---|