As you already know, the Raspberry Pi is a wonderful nano-computer with a lot of features. By default, the Raspbian OS is configured to be used as a desktop computer. But it’s better used like a server! To do that, we need to perform some cleanup (i.e. removing useless packages) and add some additional packages to convert our Pi into a real server!
Setting a static IP
Before starting, you should have set a local static IP. Click here to learn how.
If you have a dynamic IP address from your ISP, you should use No-IP or something similar in order to access the Pi from anywhere. Click here to learn how.
Removing useless packages
The commands below removes all desktop useless packages.
1 2 3 4 |
sudo apt-get remove --purge bluej claws-mail claws-mail-i18n geany geany-common greenfoot idle idle3 libreoffice libreoffice-core libreoffice-common libreoffice-style-galaxy minecraft-pi nodered nuscratch python-minecraftpi scratch sense-emu-tools sense-hat sonic-pi wolfram-engine rm -rf ~/python_games sudo apt-get autoremove sudo reboot |
After that, we have a more lighter Raspbian OS.
Updating the Pi
Now it’s time to update your Pi, to be sure you use the latest packages.
Enter the following:
1 2 |
sudo apt-get update sudo apt-get upgrade -y |
If you want, you can upgrade the distribution if you have installed your Pi long time ago:
1 |
sudo apt-get dist-upgrade -y |
Then, you can update the Pi firmware too:
1 |
sudo rpi-update |
Then to finish the update, your reboot the Pi:
1 |
sudo reboot |
Creating an update script
It’s a good idea to create a shell script to execute these commands regularly:
1 2 |
sudo mkdir /opt/scripts/ sudo nano /opt/scripts/upgrade-pi |
The copy the following in that script:
1 2 3 4 5 6 7 8 9 |
#!/usr/bin/env bash apt-get update apt-get upgrade -y apt-get dist-upgrade -y apt-get autoremove -y rpi-update reboot |
Then hit CTRL + X and Y to save.
Make it executable:
1 |
sudo chmod +x /opt/scripts/upgrade-pi |
And now, you can execute it by :
1 |
sudo /opt/scripts/upgrade-pi |
Or you can use cron to execute it regularly automatically if you want, but I dislike this since I want to check the compatibility before doing anything!
Installing xRDP (Optional)
xRDP is a great package to access the Raspberry Pi throught RDP, which is the Microsoft‘s technology to use a computer remotely. Of course this is useful if your daily computer is Windows-based! In that case, you should run the mstsc executable. If you have an Unix system like Ubuntu or MacOS X, you can use Remmina (which is a RDP client) or just stick with SSH (which is enabled by default in Raspbian)!
To install it, follow this guide, or follow the steps summarized below.
The first thing to do is to disable the RealVNC client that comes installed with the latest Raspbian image because it causes some problems to xRDP.
Enter the following command:
1 |
sudo raspi-config |
Choose the 5 Interfacing Options option, then P3 VNC . Disable it when asked. After that, install the xRDP package:
1 2 3 |
sudo apt-get update sudo apt-get install xrdp sudo apt-get install vnc4server |
Finalize by solving the ‘X’ cursor problem:
1 2 3 |
cd ~ echo "xsetroot -cursor_name left_ptr&" > .xsessionrc chmod +x .xsessionrc |
Now your Raspberry Pi can be accessed by xRDP.
Done!
So now you have a clean and ready Pi to be used as a server! 🙂