Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

LISTING 2.3 Attempting a Reboot Without sudo


pi@raspberrypi ~ $ reboot
reboot: must be superuser.
pi@raspberrypi ~

By the Way: Getting to Know sudo
You cannot run some commands unless you have special privileges. For
example, the root user, also called the superuser, is an account that was
originally set up in Linux as an all-powerful user login. Its primary purpose
was to allow someone to properly administer the system. In some ways, the
root account is similar to the administrator account in Microsoft Windows.
Due to security concerns, it is best to avoid logging into the root user account.
On Raspbian, you are not even allowed to log into the root user account!
So how do you run commands for which you need root privileges, such as
installing software or rebooting your Pi? The sudo command helps you here.
sudo stands for “superuser do.” User accounts that are allowed to use sudo
can perform administrative duties. The pi user account on your Raspberry Pi
is, by default, granted access to the sudo command. Therefore, if you are
logged into the pi account, you can put the sudo command in front of any
command that needs superuser privileges.


  1. Type the command sudo reboot and press the Enter key. Your Raspberry Pi
    should now reboot.

  2. At the raspberrypi login: prompt, type pi and press the Enter key. You
    should now see the Password: prompt.

  3. At the Password: prompt, type raspberry and press the Enter key. If you are
    successful, you see the pi@raspberrypi ~ $ prompt. If you are not successful,
    you get the message Login incorrect and see the raspberry pi login:
    prompt again.

  4. To change the password for the pi account from the default to something new, type
    in the command sudo raspi-config and press the Enter key. You should see
    the text-based menu you saw when you first booted your Raspberry Pi:


Click here to view code image


Raspi-config
info Information about this tool
expand_rootfs Expand root partition to fill SD card
overscan Change overscan
configure_keyboard Set keyboard layout
change_pass Change password for 'pi' user
change_locale Set locale
change_timezone Set timezone
memory_split Change memory split
overclock Configure overclocking
ssh Enable or disable ssh server
Free download pdf