How to Setup a Raspberry Pi
By Raymond Li (Raymo111), December 7th, 2018
Last updated April 14th, 2020
Table of Contents
Step 0: Hardware Prerequisites
You will need the following prerequisites:
A Raspberry Pi. I'm using a Pi3 Model B that comes with built-in bluetooth, WiFi, 4 USB ports, HDMI, audio jack, and a standard Android Power Outlet.
A microSD card to host the Pi's OS on. You may need an adapter if your computer doesn't support just plugging in MicroSD Cards.
A Computer to flash your MicroSD Card from and read this tutorial on.
Keyboard, Screen, HDMI cable, Ethernet cable, standard Android power cable. I'll assume you have the hardware above, so let's get started.
Step 1: Flash Your MicroSD Card
Plug your MicroSD Card into your computer.
Download and install Etcher.
Download and unzip Raspbian Stretch Lite. This is a command-line based, no-desktop very-lightweight version of Raspbian. It should download relatively fast, as it is only 351MB (for the November 2018 Version)
Open Etcher and choose the .ISO file you've unzipped containing your Raspbian OS, and choose your MicroSD Card. Click Flash, and wait for it to finish. You may get several popups from Explorer if you're on Windows, but you can just ignore them.
Eject and remove your MicroSD Card from your computer.
Make sure your Pi is unplugged. Insert the MicroSD Card you just flashed into your Pi.
Connect a keyboard, screen (via the HDMI port), and ethernet cable to your Pi. Plug the Pi's power cable in, and it should boot up automatically.
Step 2: Configuring Your Pi
- When you see
raspberrypi login:and a blinking cursor at the bottom of your screen, type in
for the login and then hit enter. The default password is
We'll change it in a minute.
- Type in
sudo apt update
This command updates all the sources that Raspbian pulls updates from.
apt is a package manager.
sudo means super-used do, meaning that you get elevated priviledges when you run the command.
You might have seen
apt is newer and more user-friendly. Wait for the command to finish.
- When you see
pi@raspberrypi:~ $again, this means that the command you've executed has finished. Go ahead and type
sudo apt full-upgrade
when prompted. This may take a while, but do watch the progress bar on the bottom of your screen.
- When your Pi has finished updating, do
sudo apt autoremove && sudo apt clean
This removes all unnecessary packages and saves you memory. The
&& joins multiple lines of commands together so you only need to type one line.
This gets you into a blue graphical screen where you can use the arrow keys to choose and enter to select different options. Use the arrow keys to select
8 Update and hit enter to update the configuration tool.
- Wait for a few seconds, then scroll down to
4. Localisation Optionsand enter. Hit enter again to change your locale. Scroll down to
en_GB.UTF-8 UTF-8and hit the spacebar to deselect it if there is an asterisk next to it. Keep scrolling down to
en_US.UTF-8 UTF-8and hit the spacebar to select it. Then hit enter to finalize your changes. Use the down arrow to scroll down to en_US.UTF-8. Hit enter once and wait for it to go back to the
4. Localisation Options using your arrow keys and enter it again. This time, go to I2 with your down arrow, and change your timezone. Wait a moment, then use your arrow keys to select first your continent, then your city. I choose
America. If you're in the US, you can go into
US and choose your region if you want to.
Go back to
4. Localisation Optionsagain and choose the keyboard you're using. I'm using a
Dell USB Multimedia Keyboard. CHoose yours and enter. Now if you're in the UK, you can select the keyboard layout you want. But if you're not, then go down to
otherand choose the keyboard layout that your keyboard has. I'm going to choose English (US). After you enter, choose the version of your keyboard layout. Choose the topmost one if you don't understand the rest of the options. Enter through the Alt-gr selection and the Compose Key selection. You won't need those for now.
Finally, go back into
4. Localisation Optionsfor the last time and select
I4 Change Wi-fi Country. This is very important as you could be arrested for using the wrong wireless settings for your country. Select your country and enter. Hit enter again at the
Now go down to
7. Advanced Optionsand hit enter for
A1 Expand Filesystem. This makes sure that our Pi takes up the whole SD Card and has space to install stuff.
Change the password. Hit enter at
1 Change User Password. Follow the onscreen instructions to change your password. Finally use the right arrow twice to go to
<Finish>, and hit enter.
The last thing you should set is a hostname. Go to
2 Network Options, then
N1 Hostname. Follow the instructions, and select
Yesto reboot when done. Wait for the Pi to reboot.
Step 3: Customizing Your Pi
- When your Pi finishes rebooting, type
as the login and whatever password you set earlier on to login.
- You can remove the rainbow screen on boot with:
sudo nano /boot/config.txt
Nano is an easy to use text editor in Linux. Scroll down to the bottom with your arrow keys and add this line to the end of the text file:
Now Ctrl-x to exit nano and enter
y to save.
Reboot, and you will not see the rainbow splash again. If you want to see it for some reason, then just go back into
You just used nano to edit a file. Now use nano to edit
/etc/motd. Make sure you
sudo nano, or you will not be able to write to the file. This is the message of the day, a message you see every time you login. Make sure your cursor is at the beginning of the file, then ctrl-^ and scroll down to the end of the file. Make sure you have selected the whole file, then ctrl-k. Now, the file should be blank. Type in whatever you want to see on login, then save and exit (ctrl-x, y to save)
Now press Ctrl+D to exit the shell. Once you login again. you should see your message on the screen!
You should also set a root password with
Step 4: Setup SSH
SSH is a way to access the command line of a Linux computer remotely from another device. First, you need to set a static ip address for your Pi.
- Find your local IP address:
ip -4 a | grep global
You should see something like:
inet 192.168.2.10/24 brd 10.1.1.255 scope global eth0
192.168.2.10 is my Pi's local IP address, the address for your Pi on your own internet. The /24 is your network size, and it's most likely 24. Write your IP address down somewhere.
- Find your router's local IP address:
ip route | grep default
You should see something like:
default via 192.168.2.1 dev eth0 src 192.168.2.10 metric 202
In my case, 192.168.2.1 is my router's IP. Write this down too.
- Finally, write down the address of your DNS server, which is usually the same as your router's IP.
cat /etc/resolv.conf # Generated by resolvconf domain home nameserver 192.168.2.1 nameserver XXX.XXX.XXX.XXX
The first nameserver is the dns server you need to worry about write that down if it is different from your Router's IP.
- Next, edit
sudo nano /etc/dhcpcd.conf
You should see A whole bunch of text. These are your dhcpcd configurations. Scroll down to # Example static IP configuration and change the next few lines to:
# Example static IP configuration interface eth0 static ip_address=192.168.2.10/24 static routers=192.168.2.1 static domain_name_servers=192.168.2.1
Note that 192.168.2.10/24 is my Pi's IP address, yours would be different, the first 192.168.2.1 should be your router's IP address, and the second your DNS server's address. Now Ctrl-x and then y to save and exit, and reboot your Pi. It should now have a static IP address.
- Now enable ssh with:
sudo systemctl enable ssh sudo systemctl start ssh
Then reboot your Pi. You don't need to login.
Now, on the computer from which you're reading this, open up terminal if you're on Linux or a Mac. If you're on Windows, press the windows key and type cmd, then enter.
In your terminal, type:
Again, 192.168.2.10 is your Pi's local IP address. Enter
yes to continue connecting.
- Enter your Pi's password. If you are connected to your Pi, you should now see the message you set for login (MOTD) and you should be able to use your Pi from your own computer! At this point, you can disconnect your keyboard and screen from your Pi if you want, and simply connect to your Pi from your computer.
That's it, you've now successfully setup your Raspberry Pi!