Setup Raspberry Pi from scratch: Difference between revisions

From James's Wiki
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 18: Line 18:


Delete all partitions using 'd'<br>
Delete all partitions using 'd'<br>
Create a new partition using 'c'<br> Use the default options for everything except the endpoint (if the sd card is over 16g...use +8G for the endpoint)<br>
Create a new partition using 'n'<br> Use the default options for everything except the endpoint (if the sd card is over 16g...use +8G for the endpoint)<br>
Set partition with 't' and set to type 'b' (FAT 32)<br>
Set partition with 't' and set to type 'b' (FAT 32)<br>
Set bootable with 'a'<br>
Set bootable with 'a'<br>
Line 30: Line 30:


  sudo mkdir /media/temp
  sudo mkdir /media/temp
or do this stuff:
sudo unzip -p 2018-11-13-raspbian-stretch-lite.zip | sudo dd of=/dev/sdd bs=4M conv=fsync


Mount the newly formatted SD Card:
Mount the newly formatted SD Card:
Line 51: Line 54:
   
   
  raspberry
  raspberry
The first thing we want to do is create a new user on the system
sudo adduser <username>
After following the prompts, you are done. Next we add the new user to groups sudo and adm.
sudo adduser <username> sudo
sudo adduser <username> adm
Then we modify the password requirements for sudo so we don't have to type in our password all the time
sudo visudo
and change
%sudo  ALL=(ALL:ALL) ALL
to
%sudo  ALL=(ALL) NOPASSWD:ALL
Now logout with <code>exit</code> and log back in with your new username.
Delete the default pi user:
sudo deluser --remove-home pi
Now that the basics are done it's time to update everything for the first time as many things are probably out of date
sudo apt-get update;sudo apt-get -y dist-upgrade
After that get done:
sudo raspi-config
Change the hostname, locale, locale timezone, and make sure ssh server is turned on. After you hit finish, the RPI will reboot.
Login and:
sudo nano /etc/dhcpcd.conf
Change the settings to assign a static IP to your RPI
Now we are done with the initial setup and have a static IP we don't need the monitor and keyboard anymore so shutdown with <code>sudo shutdown -h now</code> and put your RPI where ever your putting it.
sudo apt-get install htop nmon byobu lynis logwatch ssmtp mutt ufw fail2ban fish monit

Latest revision as of 19:44, 27 January 2019

sudo apt-get install tree


To find the SD Card for you Raspberry Pi, Insert it into your computer and type:

lsblk

Assuming that you only have one similarly sized device inserted at this time it should be fairly easy to figure out which device you want based on size. If your using a Linux distro like Ubuntu, it will automaticly mount your SD Card, and you don't want that so umount it with:

sudo umount /dev/<device number>

Repeat this command adjusting the device number until all partitions are unmounted.

Next, we need to repartition the SD card with fdisk.

sudo fdisk /dev/<device number>

Delete all partitions using 'd'
Create a new partition using 'n'
Use the default options for everything except the endpoint (if the sd card is over 16g...use +8G for the endpoint)
Set partition with 't' and set to type 'b' (FAT 32)
Set bootable with 'a'
Write changes with 'w'

Create a new filesystem on the SD card. (format it)

sudo mkfs.vfat /dev/<device number>

Next I create a directory that I use for temporarily mounting devices:

sudo mkdir /media/temp

or do this stuff:

sudo unzip -p 2018-11-13-raspbian-stretch-lite.zip | sudo dd of=/dev/sdd bs=4M conv=fsync

Mount the newly formatted SD Card:

sudo mount /dev/<device number> /media/temp/

Unzip NOOBS to the SD card:

sudo unzip Downloads/NOOBS_lite_v2_4.zip -d /media/temp/

unmount the device before removing it:

sudo umount /dev/<device number>

Now you can insert the SD card into your RPI, hook it up to a keyboard and monitor, and power it up.

After it boots up log in by typing the following at the prompt

pi

The default password is:

raspberry

The first thing we want to do is create a new user on the system

sudo adduser <username>

After following the prompts, you are done. Next we add the new user to groups sudo and adm.

sudo adduser <username> sudo
sudo adduser <username> adm

Then we modify the password requirements for sudo so we don't have to type in our password all the time

sudo visudo

and change

%sudo   ALL=(ALL:ALL) ALL

to

%sudo   ALL=(ALL) NOPASSWD:ALL

Now logout with exit and log back in with your new username. Delete the default pi user:

sudo deluser --remove-home pi

Now that the basics are done it's time to update everything for the first time as many things are probably out of date

sudo apt-get update;sudo apt-get -y dist-upgrade

After that get done:

sudo raspi-config

Change the hostname, locale, locale timezone, and make sure ssh server is turned on. After you hit finish, the RPI will reboot.

Login and:

sudo nano /etc/dhcpcd.conf

Change the settings to assign a static IP to your RPI

Now we are done with the initial setup and have a static IP we don't need the monitor and keyboard anymore so shutdown with sudo shutdown -h now and put your RPI where ever your putting it.

sudo apt-get install htop nmon byobu lynis logwatch ssmtp mutt ufw fail2ban fish monit