The Pi is installed now what do we do?
Make user accounts, file permissions, install a webserver
Users & Groups
Making a new user on the Pi
sudo adduser USERNAME
Add this user to the sudo group
sudo addgroup USERNAME GROUPNAME
sudo addgroup USERNAME sudo
Logout of the current ssh connection
Now log in with your new user
Try to see if your sudo powers work
Let's remove the user "pi".
It's not safe to keep the default user and password logins enabled.
Note! This means that you can only login with the useraccount you just made, so don't loose your password!
sudo deluser pi
If it does not work, it could be that the user pi is still being used. Try to reboot the pi and do it again.
sudo reboot ssh USERNAME@ip-adress sudo deluser pi
Change the hostname of the Pi
You can change this name, by editing these two files:
sudo nano /etc/hostname sudo nano /etc/hosts
Change /etc/hosts into:
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 127.0.1.1 newhostname (needs to be the same as your hostname)
The hostname will be changed after a reboot.
So reboot and ssh in again.
sudo reboot ssh USERNAME@ip-address
Install a webserver
So we can host webpages on our Pi, that can be reached when we type the ip-address in the browser.
sudo apt install nginx
Once it's done, let's go to the folder that nginx uses to serve files from:
And try to check if nginx serves you a file in the browser, by visiting the ip address of your pi, for example:
To edit this page, remove the standard index file and make a new index.html file
You might get a permission denied error now.....
This is because the
/var/www/html/ is not configured with the right permissions.
Let's make a group for all the users on this pi,
we will give this group the permissions to write in this folder.
sudo addgroup USERNAME users
Let's take a look at file permissions How do you know the permission settings of a file? And how do you change them?
(This is documented here too: https://pzwiki.wdka.nl/mediadesign/Shell_Cheat_Sheet#File_Permissions )
total 24 drwxr-xr-x 3 flo flo 4096 Mar 4 16:03 . drwxr-xr-x 6 root root 4096 Mar 4 15:41 .. -rw-r--r-- 1 flo flo 220 Mar 4 15:41 .bash_logout -rw-r--r-- 1 flo flo 3523 Mar 4 15:41 .bashrc drwx------ 3 flo flo 4096 Mar 4 16:03 .gnupg -rw-r--r-- 1 flo flo 807 Mar 4 15:41 .profile
Let's unpack this!
d = directory
rwx rwx rwx U G O
u = user g = group o = other
user has the permission to: rwx (read, write, execute) group has the permission to: r-x (read, execute) other has the permission to: r-x (read, execute)
Two programs can be used to change ownership and permissions:
chown = change ownership (Ownership is split up in a user and a group) chmod = change modes (Modes are the filesystem permissions given to user, group and others classes to access files under Unix.)
To see the permissions of the /var/www/html folder
ls -l /var/www/
total 12 drwxr-xr-x 3 root root 4096 Mar 4 15:57 . drwxr-xr-x 12 root root 4096 Mar 4 15:57 .. drwxr-xr-x 2 root root 4096 Mar 4 15:58 html
Let's unpack this again!
d rwx r-x r-x U G O
U = rwx G = r-x O = r-x
owned by user: root owned by group: root
We want to change the permissions and ownership to:
user: root (or anything else) group: users (this is the shared group that we just made) G = rwx (read, write and execute permissions)
To change ownership to user=root and group=users:
chown -R root:users /var/www/html/
To change permissions of group:
chmod -R g+w /var/www/html/
Check if it worked:
And try to edit the index.html file now in /var/www/html/