loading

Introduction

After turning Raspberry Pi into a multi-user desktop environment, we will find that all users (except pi) are very restricted in the system-level commands they can run. For example, clicking on the shutdown or reboot buttons doesn't work because these users don't have the privilege to run the shutdown or reboot commands.

Solution

sudoer policy detemines the privileges with respect to the commands.

Prerequisite

Complete the "Turn Raspberry Pi into a multi-user desktop environment" instructable.

Scope

This instructable will show how to:

  • Configure the sudoer policy file
  • Test

Environment

The following are data of the 2 Raspberry Pi:

Distributor ID: Debian

Description: Debian GNU/Linux 7.8 (wheezy)

Release: 7.8

Codename: wheezy

Linux rpipro.example.com 3.18.9+ #767 PREEMPT Sat Mar 7 21:41:13 GMT 2015 armv6l GNU/Linux

References

man 5 sudoers

Step 1: Turn Raspberry Pi Into a Multi-user Desktop Environment

Step 2: Activate the Password for Root (Optional)

If we make a mistake in sudoers policy file, the pi account's sudo privilege will not function. This means we are NOT able to do any sort of configuration as it requires the sudo privilege and therefore the system prevents us from fixing the error in sudoers policy file. This is very troublesome. I know of two solutions:

  1. Activate the password for root
  2. Shutdown Raspberry Pi device, pull out the SD card. Find a running Linux system with an SD care reader. Insert the SD card into the D care reader. The running Linux will mount the SD card under /media/xxxxxx. Enter that directory and fix the sudoers policy file.

I prefer the first solution and as such this instructable will cover the first solution.

Open terminal emulator

Change root password:

sudo passwd root

Step 3: Add a Test User (Optional)

You may skip this step if you have previously created a user. Use the user id that you previously created for the next step.

Open terminal emulator

sudo useradd jill
sudo passwd jill

Step 4: Assign Shutdown and Reboot Privileges to User

Open terminal emulator

Determine the full path to shutdown command:

which shutdown

Output:

/sbin/shutdown

Determine the full path to reboot command:

which reboot

Output:

/sbin/reboot

Create a new sudoers policy file to to include shutdown and reboot commands as new privileges

sudo vi /etc/sudoers.d/common_users
<br>User_Alias      PLEBEIANS = jill
<br>PLEBEIANS    ALL = NOPASSWD: /sbin/reboot, /sbin/shutdown

Save the file

Note:

If we want to add more commands besides those 2, add a new command next to "/sbin/shutdown". Each command is seperated by comma and 1 space.

If you want to add more users to have the two privilege, add new user next to "jill". Each user is seperated by comma and 1 space.

Step 5: Test Reboot and Shutdown

Click on Main Menu -> Shutdown -> Reboot

Click OK

Expected Result: The Reaspberry Pi device reboots

Step 5 Test Shutdown

Click on Main Menu -> Shutdown -> Shutdown

Click OK

Expected Result: The Reaspberry Pi device shutdown

Step 6: Debug (If Necessary)

If you completed "Activate the password for root" step:

Open terminal emulator

su -

Type root password and press ENTER

vi /etc/sudoers.d/common_users

Make the necessary changes and save the file.

Repeat "Test Reboot and Shutdown" step

About This Instructable

4,111views

11favorites

Bio: Systems Administrator and Software Programmer.
More by mirza irwan osman:Install Modem USB Device in Raspberry Pi Make the Volume Knob of Sound Blaster X-Fi Surround 5.1 Pro Sound Card Work in Raspberry Pi Create a Volume Control for USB Sound Card in Raspberry Pi 
Add instructable to: