HIDDEN HACKS FOR RASPBERRY PI
Get more from your microcomputer with these clever tricks
By Lucy Hattersley
Raspberry Pi is an incredibly versatile computer that delivers much more power and functionality than its small stature suggests. Now, with ten years of solid development behind it, Raspberry Pi computers and Raspberry Pi OS are packed with activity. Hidden in amongst all the hardware and software are some real gems of tricks that you can use to learn more about computing, make better projects, and get far more out of Raspberry Pi than you ever thought possible. In this feature, we’re going to unearth hidden hacks and handy tricks that every talented Raspberry Pi owner should know.
Get under the hood of Raspberry Pi OS
Set up a new user
As a security measure, you should set up a custom user name, rather than using the default ‘pi’ user that has been used in Raspberry Pi OS (and previously Raspbian) since the beginning. Get on board with improved security and create your own new user account. Create new users in Raspberry Pi OS with **adduser** and the desired username (in this example, ‘izzy’): sudo adduser izzy You will be prompted for a password for the new user, izzy. Enter a password for security reasons. Terminal will ask for the Full Name, Room Number, Work Phone, Home Phone, and Other information. Press RETURN to keep these blank and enter ‘y’ to ‘Is the information correct?’ When you create a new user, they will have a home folder in **/home/**. Upon creating a new user, the contents of **/etc/skel/** will be copied to the new user’s home folder. You can add or modify dot-files such as the **.bashrc** in **/etc/skel/** to your requirements, and this version will be applied to the new users.
Overlay File System
Overlay File System keeps Raspberry Pi OS in a fresh state. With Overlay File System enabled, any changes you make are saved to RAM instead of storage, and are lost when you reboot. This is useful for using Raspberry Pi in a public setting where you want people to be able to use the operating system without making any permanent changes to it. Such as with a Raspberry Pi set up in a store. Open Raspberry Pi Configuration and choose the Performance tab. Click Configure next to Overlay File System and enable User Overlay. The write-protect boot partition enables you to lock down the boot partition for even more security.
Take a look at the kernel!
Raspberry Pi kernel is stored in GitHub ( **github.com/raspberrypi/linux** ). It follows behind the main Linux kernel. Raspberry Pi takes long-term releases of the kernel, which is mentioned on GitHub, and integrates the changes into Raspberry Pi kernel. There is also a ‘next’ branch that contains an unstable port of the kernel. After extensive testing and discussion, the next branch becomes the main branch.
Switch users
The **su** command (related to **sudo**, which we’ll look at later) is used to ‘switch user’. **su izzy** …will switch between your current user and izzy. Use **whoami** to see which user you’re currently using. **whoami** …will return ‘izzy’. You’ll be in the **pi** folder still so use **cd** to switch to izzy’s folder. **cd /home/izzy** Use **ls** and you’ll see the files created by **/etc/skel**.
Move to 64-bit
If you’ve been running Raspberry Pi OS for a while, the chances are you’re using the 32-bit version. It’s time to double-up to the latest, 64-bit edition. This came out of early beta testing last month, and can now be found inside Raspberry Pi Imager (**magpi.cc/imager**). If you have a Zero 2 W, Raspberry Pi 3, Raspberry Pi 4, or Raspberry Pi 400, then make the switch to Raspberry Pi OS (64-bit). Read Gordon Hollingworth’s blog for a detailed write-up (**magpi.cc/64bit**).
Sudoers list
The default user on Raspberry Pi OS is a member of the sudo group, which enables it to perform elevated actions (as root) when you use the **sudo** command. To add your new user to the sudo group, use: **sudo adduser izzy sudo** Now they’ll also be able to use **sudo**.
“Chances are you’re using the 32-bit version of Raspberry Pi OS”
Updating Raspberry Pi
It’s best to update Raspberry Pi OS using the built-in Software Updater tool. You should do this frequently. It’s important to keep Raspberry Pi OS up-to-date for security purposes, and also to ensure you are running the latest version, which will contain fewer bugs. It is also possible to update Raspberry Pi OS using APT (Advanced Packaging Tool) in Terminal, but make sure to do a full upgrade (rather than just a regular upgrade). **sudo apt update** **sudo apt full-upgrade** Using **full-upgrade** (over just regular **upgrade**) ensures that APT picks up any dependency changes that have been made.
TAKE CONTROL OF YOUR RASPBERRY PI
Take control of your Raspberry Pi from across a network
Copy files with SCP
After you have connected to Raspberry via SSH (or VNC), you’ll soon wonder how to copy files to and from a remote computer on the network. There are a few different ways to copy files, and we generally prefer to use SCP (secure copy). While in Terminal on your source computer, you use the **scp** command with the SSH login details and file location (separated by a colon). It looks like this: **scp <user@IP>:path/to/file path/to/destination** Let’s say we want to copy a file called **test.txt** from the Desktop on our Raspberry Pi to the Desktop on our remote computer, we would enter: **scp pi@192.168.0.40:/home/lucy/Desktop/test.txt /home/lucy/** We find it less wordy to navigate to the destination folder on our computer, and then use a dot ‘.’ as the destination to copy the file to the current location **cd ~/Desktop** **scp pi@192.168.0.40:/home/lucy/Desktop/test.txt .** If you copy a lot of files, you can install FTP (File Transfer Protocol software) like FileZilla (**filezilla-project.org**) and use it to transfer files across computers on your network.
Remote control: VNC
VNC enables you to remotely access Raspberry Pi from another computer. VNC is a graphical desktop system that lets you view the desktop of Raspberry Pi OS from a window in another computer. To do this, you’ll need to activate server software in Raspberry Pi OS and install viewer software on your other computer (this can be a Mac, PC, or Linux computer, or another Raspberry Pi). Raspberry Pi OS comes with VNC Server built in. All you need to do is turn it on. Open Raspberry Pi Configuration (menu > Preferences > Raspberry Pi Configuration) and choose Interfaces. Set VNC to On and click OK. The VNC Server icon will appear in the menu bar. Click it to open the VNC Server window, and you will see the IP address underneath. You will most likely need to install VNC Viewer on the other computer (**magpi.cc/vncviewer**). Once installed, open the IP address of your Raspberry Pi into the text bar of VNC Viewer and press RETURN. Enter the Username and Password for Raspberry Pi OS and click OK. You will now be able to remotely access Raspberry Pi OS desktop in a window on your remote computer. Take a look at **magpi.cc/vnc** for more information.