CS 326 Operating Systems

Raspberry Pi Administration Tips

Note: you must be logged in as root or use sudo to install packages and configure your system. The Following tips assume you are logged in as the root user. To do this, type su - and then enter your root password.

If you are used to the sudo command, you can install it with the instructions below. However, it’s often easier to just log in as root while you’re issuing several system administration commands.

Setting the Time Zone

Your Pi is configured to sync its clock via NTP (network time protocol). However, the default time zone is UTC, so if you run the date command or similar you will get the wrong time. Let’s update the time zone:

$ timedatectl status
               Local time: Sat 2018-10-13 22:53:18 UTC
           Universal time: Sat 2018-10-13 22:53:18 UTC
                 RTC time: n/a
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

# Ok, we're in UTC. Let's update this. To find our time zone, we can
# use the following command:
$ timedatectl list-timezones

# This opens a pager with a list of zones. Scroll through to find a
# suitable time zone, take note of its full name
# (e.g., 'America/Mexico_City'), then press q to quit.
# Let's set the clock to PT. First, switch to root if you haven't already:
$ su -
$ timedatectl set-timezone America/Los_Angeles
$ date
(The current, correct time should print)

Setting the Locale

You should set up your locale to ensure text, locations, times, etc. are properly rendered. Doing this is not required, but will make using your Pi a little bit easier.

$ vim /etc/locale.gen

# Uncomment your locale in the file, like below (I used en_US):

#en_PH ISO-8859-1  
#en_SG.UTF-8 UTF-8 
#en_SG ISO-8859-1  
en_US.UTF-8 UTF-8  
en_US ISO-8859-1   
#en_ZA.UTF-8 UTF-8 
#en_ZA ISO-8859-1  
#en_ZM UTF-8       

Then run:

$ locale-gen
Generating locales...
  en_US.UTF-8... done
  en_US.ISO-8859-1... done
Generation complete.

Installing Software

# To install a package:
$ pacman -S vim

# To search for packages:
$ pacman -Ss python

# Update the package index (if a download fails due to old index):
$ pacman -Sy

# Update the package index and installed packages:
$ pacman -Syu

Installing Sudo

You might be surprised to find out the sudo command is a package that you have to install first on Arch Linux. To set it up, you’ll need to install the package and configure the ‘sudoers’ file:

$ pacman -S sudo

# Edit the sudoers file with the following command:
$ visudo

# Scroll to the bottom of the the sudoers file (type 'G' in vim) and uncomment
# this line (just remove the # before %wheel):
## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL

# Finally, add your regular user account to the 'wheel' group:
$ gpasswd -a mmalensek wheel
Adding user mmalensek to group wheel

You will have to log out of your user account and back in before the changes take effect. Then you can use sudo as usual:

$ sudo pacman -S htop

Internet Connection Sharing

The default setup will get your Pi on the WiFi, and will also automatically connect to wired networks via Ethernet. If you follow Prof. Benson’s network configuration instructions, then you can use your USB Ethernet adapter to share your computer’s internet connection with the Pi.