Getting started with Raspberry pi using command line only

Rishi
3 min readNov 21, 2020

Download and install Raspberry PI Imager for your appropriate for your operating system. Select Raspberry Pi OS Lite (32-bit) Operating System, select your SD card and click on Write.

Once write is complete the Imager will eject your card automatically. Remove and insert your card again. You will notice that the SD card is now mounted as ‘boot’ (on macOs /Volumes/boot). Before we install the card on RPI we need to perform few steps.

Enable SSH:

Enable SSH by creating a empty file called ssh on the sd card.

$ touch /Volumes/boot ssh

Connect to wifi (optional):

This setup might be slightly different for different PI’s and OS. Please check the below guide on raspberrypi.org for most latest information.

Create a new file call wpa_supplicatn.conf on the sd card.

nano /Volumes/boot/wpa_supplicant.conf

Add below lines to the file and update the LAN ssid and password accordingly.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
ssid="<Name of your wireless LAN>"
psk="<Password for your wireless LAN>"
}

Eject the card and insert it into the RPI and connect to the power source. There are many trivial methods to find out the ip address of the connected devices on your network. Once its running you can SSH to the RPI using the ip address or hostname. By default the username for the RPI is pi and password is raspberry . It is highly recommended to changes the password as soon as possible.

$ ssh pi@raspberrypi
The authenticity of host 'raspberrypi (192.168.xx.xx)' can't be established.
ECDSA key fingerprint is SHA256:xxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
$ pi@raspberrypi's password:

After connecting you will see a warning about the default password

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

Change password and raspi-config:

$ sudo apt update
$ sudo apt upgrade

Once update is complete. Run raspi-config

$ sudo raspi-config

This will pop open the raspi-config tool.

Some of the important configurations you should update:

  1. Default password
  2. Localization Options -> Locale, Timezone, keyboard layout and WLAN country.
  3. Interfacing Options -> Camera, SPI,I2C etc (depends on your use)
  4. Finish and reboot. Login with new password.

Login without password (Optional):

$ ssh-copy-id pi@<ip address>
$ <enter password on prompt>
$ ssh pi@<ip address> # connects to rpi without password

--

--