How to get connected

Cool, so we have a base install of Raspberry Pi OS and we can connect to the Pi on the local network. To be able to connect to it from anywhere, let’s set this up. We kind of lay the Pi to the side and focus on your home router. We are going to do some port forwarding and create a dynamic DNS name.

As about every internet provider comes up with their own router, it is a bit tricky to create up a general manual. Luckily we have the internet to help out here. On https://portforward.com/router.htm you should be able to find your router and find the correct way to setup a port forward.

You want to forward port 22 from the internet to port 22 on your Raspberry Pi’s IP address.

Also a lot of Internet providers do not provide you with a static IP address, we want to do another step to be able to simply reach your Raspberry Pi from anywhere in the world. We setup Dynamic DNS. For this we use the free after registration service of DuckDNS

  • Go to DuckDNS and login with one of the login options
  • Create a DuckDNS subdomain
  • Add the domain to your router

DuckDNS ducky logo

Where am I – Basic CLI

The Linux command line is powerful, but it might take a bit getting used to. In this lesson we start with some navigation and we’ll play with some files. Fun fact, a lot of these commands also work on the Mac command line.

In general when you login into a machine through SSH you’ll end up in the home directory of a user. In this case /home/pi but than. Here is a list of commands and a short explanation of their use.
Now that you have access to the command line, you can give them a try. We’ll get back to them later on in more detail.

CommandExplanation
lslist, show the content of the directory. Similar to dir in Windows
cdchange directory
clearclear the output on the screen
mkdirmake directory
rmdirremove empty directory
touchcreate file
rm remove file or not empty directory
cpcopy
mvmove
manmanual, works on all commands

When you are familiar with these basic commands, you can check out the following.

CommandExplanation
catdisplay content of a file
echoadd text to a file – compare > and >>
dfshow available/used disk space
du disk usage, show how the directory is build up
hostnameto find out the name of the machine
unamefind information about system, like distro, kernel, processor
sudosuper user do, in front of a command to have root privileges
aptdebian family packate manager
chmodchange access rights
chownchange owner/group
tar(un)pack tarball archives
unzipunpack zip archives

You can use your arrow keys (up and down) to go to to previous typed command, which saves typing.

Let’s start at the start

wiser.pepoweb.com was started to share my Linux knowledge with some coworkers. It is the central place to keep track of the lessons we create together.
We start with a Raspberry Pi 4 and raspbian and go from there.

So as there are enough manuals on the internet with a step by step how to on installing an OS on a Pi, I am not going to bore you with yet another write out. I’ll just list the steps to create a headless setup, so we don’t need additional hardware and wires, except for a network wire. If you need additional information you can follow the link at the bottom.

  • Download the Raspberry Pi imager from https://www.raspberrypi.com/software/
  • Run the imager on a computer with an SD card reader
    • Pick the OS you want to install (other light)
    • Pick the SD card you want to install it on
    • Press Write
      ! You can easily enable SSH by pressing Ctrl (Cmd) + Shift + x and enable SSH before hitting the Write button.
      ! Here you can also setup Wifi, if you are not using a wired connection.
  • Once done, create an empty file in the boot partition called ssh
  • Put the SD card in the Pi, connect it with a network cable to your router and power it up.
  • Get the IP address of the pi by one of these options:
    • ping raspberrypi.local
    • from the DHCP table in your router
    • A 3rd party tools to find out the IP
  • SSH into your Pi using: ssh pi@<ipaddress> the default password is raspberry

Welcome to the Linux command line 🙂

Now the first thing you want to do is change the default password. Type passwd and then enter the default password and two times a new password you create.