Book Image

Learning Raspberry Pi

By : Samarth Shah, Serge Schneider
Book Image

Learning Raspberry Pi

By: Samarth Shah, Serge Schneider

Overview of this book

Table of Contents (14 chapters)
Learning Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

User management


Once you have Raspbian installed, it is advisable to set up a user account. The Raspberry Pi Foundation's version of Raspbian already has a user pi, with the password raspberry. A system running with the default password is not secure as the password is widely known. To avoid this problem, the password needs to be changed. The default install does not have a root password set and the user is expected to use sudo to run commands as root. As a result, many beginners never learn the difference between a root and a user account. This leads to misuse of sudo and other issues later on. A root password is set in order to allow administrative tasks to be carried out in a standard root shell and an extra user account is added to standardize the install using the following steps:

  1. First, log in as pi.

  2. Then, change the default user password by running the following command:

    # passwd
    
  3. Next, enter a root shell by typing this:

    # sudo -i
    
  4. Again, run passwd to change the password. As you are in a root shell, this will change the root password this time.

  5. Add a new user with a name of your choice by entering the following command:

    # adduser steve
    
  6. The user will not be able to carry out certain tasks without being a member of the relevant groups. The following command will add the user into the major groups:

    # usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev, input,spi,gpio steve
    

Note

Please note that raspi-config is coded with the assumption that pi is the main user. As a result, some options (Enable Boot to Desktop/Scratch), will not work as expected.

If you would like to boot the desktop automatically as the new user, this can be easily accomplished without raspi-config:

  1. First, enable the LightDM service by running this:

    # update-rc.d lightdmd enable 2
    
  2. Set the autologin-user variable in /etc/lightdm/lightdm.conf as required. You should note that leaving it commented out with a # will present you with a login window every time you boot up, which is slightly more secure and is especially recommended if you have multiple users.

The reverse can be accomplished simply by disabling the LightDM service.

Once you installed the operating system, you can use the keyboard, mouse, and HDMI screen to get started with the development. However, many of you might not have a USB keyboard, USB mouse, and HDMI screen. In such cases, you need to access Raspberry Pi remotely.