Exploring Raspberry Pi 3 And Raspbian Jessie Lite

The Experiment: In this experiment were going to explore the Raspberry Pi and Raspbian Jessie Lite. The content on this page is for reference use only.

Table of Contents
1. What i a Respsberry Pi
2. Handy Window Tools
3. Installing Raspbian Jessie Lite
Prepare Your SD CardPi
• Disable auto file system expansion in new Jessie image
Hook Up Your Raspberry Pi
Configure Your RaspberryPi
Get Your Raspberry Pi IP address
4. After The Raspbian Jessie Lite Install
Change the default “pi” password
Update / Upgrade
Create a user
Remove a user
5. The Network
Set a Static IP Address
6. USB Drives
Installing a USB Flash Drive
7. Set the default Audio device in Raspbian Jessie Lite
8. Command Notes



What is a Raspberry Pi
The Raspberry Pi 3 is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python.
^Top



Handy Windows Tools
1. PUTTY (SSH client)
2. WinSCP (SSH File Transfer)
3. Win32DiskImager
4. SD Formatter
^Top



Installing Raspbian Jessie Lite
You will need: A 8GB Class 4 SD card (or better), A HMDI to VGA adapter, Video cable or A HDMI to DVI cableA VGA monitor or TVA USB keyboard,  A USB mouseEthernet cable.


Prepare Your SD Card
1. Download Raspbian Jessie Lite (windows .zip)
2. Un-zip the RRaspbian Jessie Lite image (write down the folder name)
3. Launch Win32DiskImager
4. Select the Raspbian Jessie Lite.img file
5. Select the device (SD card drive letter)
6. Leave Copy (un-ckecked)
7. Click Write (this will take at least 30minutes)
8. Un-plug the SD card

Disable auto file system expansion in new Jessie image
1. Before plugging the SD card into the raspberry Pi, open the SD card directory:
Edit the file: cmdline.txt
Remove the following text: init=/usr/lib/raspi-config/init_resize.sh
2. The above will stop file system expansion at first time boot.
3. This  is only necessary if you want to resize the file system for a usable .img backup.
See : Raspberry Pi Image Too Big For Same Size SD Card

Hook Up Your Raspberry Pi
1. Place the SD card into the raspberry Pi SD slot
2. Connect everything to the Raspberry Pi
3. Now connect your Raspberry Pi to the micro USB power adapter

It’ll turn on all by itself and you should see it boot for the first time

Configure Your Raspberry Pi
raspberrypi login: pi <enter>
password: raspberry <enter>
Now type:
pi@raspberrypi ~$ raspi-config <enter>

Note: I you (Disable auto file system expansion in new Jessie image)
See before the next step : Raspberry Pi Image Too Big For Same Size SD Card
1. Select expand_rootfs (the second option) and press enter
2. Confirm that you want to expand the file system and let Raspbian do its thing
3. When you’re returned to the configuration list, go all the way to the bottom and select the Finish option
4. It’ll ask you if you want to reboot. Choose yes

Get Your Raspberry Pi IP address
raspberrypi login: pi <enter>
password: raspberry <enter>
Now type:
pi@raspberrypi ~$ ifconfig <enter>

Write down the inet addr:

Now if you have the PUTTY(Client) installed on your PC you can remotely access your Raspberry Pi with that IP address

^Top



After The Raspbian Jessie Lite Install


Change the default “pi” password:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To change the “pi” password type:
pi@raspberrypi ~$ passwd <enter>

The passwd command allows you to change your password, you will be prompted for your old password, then you new password twice. Once this is done then the next time you log in you will need to use the new password.

Steps:
1. From a command line prompt type passwd followed by the Enter key
2. Enter your current password followed by the Enter key
3. Enter your new password followed by the Enter key
4. Re-enter your new password followed by the Enter key
5. Your password has now been changed

Now logout type:
pi@raspberrypi ~$ Logout <enter>

Now log back in with “pi” and the new password
raspberrypi login: pi <enter>
raspberrypi password: <your new password> <enter>

^Top



Update / Upgrade:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To update the system type:
pi@raspberrypi ~$ sudo apt-get update <enter>

Wait for this to complete

Now upgrade the system type:
pi@raspberrypi ~$ sudo apt-get upgrade <enter>

Wait for that to complete, answer any prompts with ‘y’ + Enter.
Your system is now up-to-date.


Last clear all downloaded package files (.deb files) from the archives folder
to free up space on the SD card type:
pi@raspberrypi ~$ sudo apt-get clean <enter>

^Top



Create a user:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To Create a new user type:
pi@raspberrypi ~$ groups <enter>

You will see a list similar to the one below:
pi adm dialout cdrom sudo audio video plugdev games users netdev input

Now to create a new user, but remember to use your list of groups (minus the first ‘pi’ item) and replace <username> with the user you want to create type:
pi@raspberrypi ~$ sudo useradd -m -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev, input <username> <enter>

Next set a password for your new user type:
pi@raspberrypi ~$ sudo passwd <usernsme> <enter>

Complete the prompts as they appear.

Now shutdown the raspberry pi type:
spi@raspberrypi ~$ sudo shutdown -h now <enter>

The raspberry pi will boot up and leave you in a Bash shell asking for a login name: Log-in with your newly created user’s name

^Top



Remove a user:
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

To Remove a user type:
pi@raspberrypi ~$ sudo deluser –remove-all-files <usernsme> <enter>

This will take a little while and spit out a lot of lines of text – eventually it will say ‘Done’. This removes user and it’s associated files from the system.

^Top



The Network:


Setting a Static IP Address
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

First, we need to edit the dhcpcd.conf:
pi@raspberrypi ~$ sudo nano /etc/dhcpcd.conf <enter>

Next we need type in the following lines at the bottom of the file:
# Set eth0 static ip address
interface eth0
static ip_address=192.168.1.xxx/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

Next we need reboot:
pi@raspberrypi ~$ sudo reboot <enter>

Then Log back in
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>
type:
pi@raspberrypi ~$ ifconfig <enter>

verify your new settings

To double checks if all is working as it should, ping your ‘Gateway’ Address type:
pi@raspberrypi ~$ ping xxx.xxx.xxx.xxx -c 10 <enter>

(the -c 10 command simply denotes that you want to ping it 10 times, if you forget to add this, it will ping the address continuously. To stop it press CTRL+C)


Quick Guide:


Installing a USB Flash Drive
raspberrypi login: pi <enter>
raspberrypi password: <your password> <enter>

Plug your Flash drive into the Pi, then type:
pi@raspberrypi ~$ sudo fdisk -l <enter>

You’ll see a list of storage devices attached to the Pi; one is the SD card, the other is the drive you just plugged in. The SD card will be the one identified as /dev/mmcblk0 and will likely have a number of ‘partitions’ listed under it. We are interested in the other one; for me that is /dev/sda, and it has one partition ‘/dev/sda1′ yours will likely be the same, but check, and use your value in the following commands rather than mine. We’re going to format the partition on the USB drive so Linux has a clean slate to use – this will erase any data on the card.

Remember to use the value you got for your USB drive if it’s different to mine type:
pi@raspberrypi ~$ sudo mkfs.ext4 /dev/ <your flash drive> <enter>

The USB drive is now blank and in a Linux native filesystem format. Now we need to mount it (i.e., let Linux actually use it)

First we create a mount point (a directory name we will access the drive from) type:
pi@raspberrypi ~$ sudo mkdir /<your director name> <enter>

and then we actually mount the drive onto that mount point type:
pi@raspberrypi ~$ sudo mount /dev/ <your flash drive> /<your director name> <enter>

The drive is now available to the root user… but no one else has permission to access it
We can change that as follows type:
pi@raspberrypi ~$ sudo chgrp -R users / your director name> <enter>

Now any user belonging to the ‘users’ group can access the drive
But they can’t write to it yet type:
pi@raspberrypi ~$ sudo chmod -R g+w / <your director name> <enter>

The last job is to set up auto-mounting. Right now, if you rebooted the Pi then the /websites directory would be inaccessible because the drive would need to be re-mounted
That’s annoying, so we’ll automate that type:
pi@raspberrypi ~$ sudo nano /etc/fstab <enter>

You’ll see a somewhat complicated looking file. We just need to add a new line to it at the bottom and separate each item on the line with a tab – be sure to press the tab key where you see [tab] instead of writing the phrase [tab] enter: /dev/YOUR flash drive [tab] /websites [tab] ext4 [tab] defaults [tab] 0 [tab] 2

Save file, Press Ctrl+X to exit, “y” then Enter to save

^Top



Set the default Audio device in Raspbian Jessie Lite
After making a lot of default USB sound card configuration changes with no success. I finally figured out what had to changed, to set the USB audio device to default .

This finally work:
1. Edit aliases.conf: sudo nano /lib/modprobe.d/aliases.conf  <enter>
Comment Out: #options snd-usb-audio index=-2
Past under comment: options snd-usb-audio index=0

2. At the end of option the list past:
# Does the reordering.
options snd slots=snd_usb_audio

Save file, Press Ctrl+X to exit, “y” then Enter to save

3. Reboot: sudo reboot

4. Log back in
raspberrypi login: pi
raspberrypi password:

5. Now list new sound card order: cat /proc/asound/modules <enter>

6. Now test the sound card: speaker-test -D sysdefault:CARD=0 <enter>

^Top



Command Notes

!$ – history function: runs last command
pwd – print name of current/working directory

mkdir – make directories

nano hello.c – create new file

^Top

Advertisements