Snajder | Raspberry Pi Zero Cookbook | E-Book | www.sack.de
E-Book

E-Book, Englisch, 422 Seiten

Snajder Raspberry Pi Zero Cookbook

Delve into the practical world of the Raspberry Pi Zero
1. Auflage 2025
ISBN: 978-1-78646-647-1
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)

Delve into the practical world of the Raspberry Pi Zero

E-Book, Englisch, 422 Seiten

ISBN: 978-1-78646-647-1
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)



The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens up a new world for the makers out there. This book will give you expertise with the Raspberry Pi Zero, providing all the necessary recipes that will get you up and running.
In this book, you will learn how to prepare your own circuits rather than buying the expensive add-ons available in the market. We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the Raspberry Pi Zero with sensors, motors, and other hardware. You will also get hands-on with interesting projects in media centers, IoT, and more.

Snajder Raspberry Pi Zero Cookbook jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


Logging in to the RPZ desktop for the first time, creating users, and rebooting


We've taken care of the initial configuration; let's wrap up this chapter by covering a few finishing touches in the configuration, creating users, and giving them power!

How to do it...


  1. After you select Finish on the tool, it will ask whether you'd like to reboot. Select Yes, and the Raspberry Pi Zero will begin its power-down process. When it starts back up, it will take you right back to the Raspbian desktop. You can reboot the Pi anytime with this command: sudo reboot now
  2. Boot Options: After your reboot completes, reopen the Terminal screen and run again. Select the third option, Boot Options. There are four different boot mode options to choose from:

    The Boot Options menu

  3. Here, you can choose to start the Raspbian desktop or just boot into a command-line interface. It also gives you choices on requiring logins or not; if automatic login is chosen, you won't need to enter the password, so if you want a little bit of security, select one of the options that require the user to log in. My preference is Text console, requiring user to login, because it gives you a bit of security and requires less CPU and memory than running the desktop. If I need the desktop, it is simple to start it with . You can do a lot with Linux just from the command line, so a lot of the time, the desktop GUI isn't necessary.
  4. Overclocking: Option 8, Overclocking, returns a rather un-fun message to the user. I'm not sure whether this is the latest version of Raspian's program or whether it applies to both the Raspberry Pi Zero and the Raspberry Pi 3, but the same message was returned on both.

    An attempt to overclock from does not return an optimistic response:

    No overclock for you!

    It was discovered in late 2015 that overclocking options on the Raspberry Pi Zero only caused it to slow down, so the latest version of does not assist with overclocking. This doesn't mean it is impossible, however-just not advised.

  5. Open the following file: $ sudo grep arm /boot/config.txt #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800
  6. This does hint that overclocking is still possible at startup using the file. Commenting out in the file to a higher frequency should work, although the Raspberry Pi community suggests that it doesn't, and perhaps even reduces performance. Even more interestingly, looking at the running settings of a Raspberry Pi Zero suggests that it is already being overclocked to 1 GHz, compared to the former setting of 700 MHz on older Raspberry Pi models: $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 1000000 $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 1000000 $ cat /sys/devices/system/cpu/cpu0/cpufreq/ scaling_available_frequencies 700000 1000000

    This output suggests that it is already running at 1 GHz and has options to run from 700 MHz to 1 GHz. You can play around with overclocking, and I suppose it was possible to push the B+ Pis to the 1.1 GHz range-you will probably see too much instability from setting it to anything much higher than that. If it becomes unusable, you should be able to recover by commenting out your change in the file from a stable machine. Now let's work on creating new users:

  7. Creating new users is very easy on Raspbian. Here, we will create one named with a home directory located in : pi@raspberrypi:~ $ sudo adduser rpz --home /home/rpz Adding user `rpz' ... Adding new group `rpz' (1002) ... Adding new user `rpz' (1002) with group `rpz' ... Creating home directory `/home/rpz' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for rpz Enter the new value, or press ENTER for the default Full Name []: Raspberry Pi Cookbook Room Number []: Work Phone []: 123-456-7890 Home Phone []: 234-456-7890 Other []: Is the information correct? [Y/n] y
  8. This will create the new user's home directory and prompt you for the password. Once you have this set up, you can log on as this user. This will give the user their own home directory in and the ability to execute applications. The users are stored in a file called .
  9. To look at your user, you can look at the end of this file: pi@rpz14101:~ $ cat /etc/passwd | tail -5 lightdm:x:109:114:Light Display Manager:/var/lib/lightdm:/bin/false pulse:x:110:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false rtkit:x:111:118:RealtimeKit,,,:/proc:/bin/false ed:x:1001:1001::/home/ed:/bin/bash rpz:x:1002:1002:Raspberry Pi Cookbook,,123-456 -7890,234-456-7890:/home/rpz:/bin/bash
  10. The last entry is the user just created: rpz:x:1002:1002:Raspberry Pi Cookbook,,123-456- 7890,234-456-7890:/home/rpz:/bin/bash

This breaks down to fields separated by a colon ():

  • is the name
  • indicates that there is an encrypted password stored in the file
  • is the user ID
  • is also the group ID, automatically generated when the user was created
  • The next few fields are user ID Information
  • is the home directory-the location the user will start in when they log on
  • is the default command shell-the shell that the user will use when logging in.

There's more...


Before logging on as your new user, you might want to give them the ability to do superuser things, like the account does. Let's take a look at how to give your new user more powers!

Note


What is this thing anyway? If you are new to Linux, it probably seems strange to see a lot of these commands start with . This command means which puts the command in a temporary elevated state. is intended to prevent regular users from being able to do something they shouldn't (such as formatting a disk or deleting a filesystem), but it gives certain users powers to do those things if they specifically ask for elevation. It also logs attempts at trying to run things with elevated permissions that users were not given permission to do. It should become more clear as we move through the cookbook, but if you find yourself typing a command, failing, and then typing it again with when you realize your mistake, you are already living the life of many experienced Linux users.

To give your user the ability to run as a superuser, use the tool:

sudo visudo

This opens an edit window of the file, which will allow you to give your new user special permissions. Look down to where the user is already set up, and add , like this:

#includedir /etc/sudoers.d pi ALL=(ALL) NOPASSWD: ALL rpz ALL=(ALL) ALL

This gives your user the same permissions as the user, but requires that you enter a password when executing something that requires elevated permissions. This way, you can prevent the unauthorized execution of things that only a superuser should execute.

You can try logging in as our new user and trying to . The command creates an empty file wherever you tell it to. If you don't have permissions to write, the command will fail. We will try logging on as our user and trying with and without , in a directory that requires elevated permission to write to. Use the command to log on as another...



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.