Saturday, February 23, 2019

Initial Configuration of Raspbian Lite using "raspi-config"

The first time you logon to a new installation of Raspbian Lite on a Raspberry Pi you have some basic initial configuration that needs to be done.  Luckily the creators of Raspbian have included a handy utility that makes this an easy task.  The utility is named raspi-config, and can be started by preceding the name of the utility with sudo to run it as root.

sudo raspi-config


This command will pull up a menu that can be navigated with the arrow keys, and menu items can be selected with [Enter].


Below are the steps I consider necessary for the initial set-up of the Raspberry Pi.  Other options are available, but will only be used for specific projects, so they won't be covered here.  For additional information regarding menu options not covered in this tutorial, take a look at the Official Documentation at raspberrypi.org.

Step 1: Change your Password


If your Raspberry Pi might ever be connected to a network, it is very important to change your password from the default for security reasons.  Even it if will not be connected to a network, it is still good practice, and will only take a moment.

Simply select option 1 on the raspi-config main menu, and you will be prompted to enter your new password.  It will ask you to enter the password a second time to confirm, and that's it!  You have updated your password, and your Pi is more secure.

Step 2: Network Options


Selecting option 2 from the main menu will take you to the Network Options sub-menu, which you can see below.


The first thing you will want to do here is to change your hostname.  Much like the password, while this is not absolutely required, it is highly recommended, and overall good practice.  The hostname will help identify your Pi on the network, allowing you to remotely logon without having to know the IP address.  In addition, when working on a network with multiple remote servers, it is convenient to have a reminer which machine you are accessing.

I like to think of changing the hostname as naming my Pi.  It can be fun to give the Pi it's own identity.

The second item under Network Options is Wifi.  This should be fairly self-explanatory.  If you would like to have your Pi connect to a wireless network, and have not already set it up through the Headless Set-up Procedure, this is where you can enter the SSID and Wifi password.

The first thing you will be asked is which country you are in.  If you do not want to scroll through the entire list to find you country, you can type the first letter of the country name, and you will automatically jump to that point in the list.

Next you will be asked for the SSID, where you will need to manually type in the SSID, or name, of the Wifi network.  Finally you will be asked for you password.  If you don't want your Pi to connect to a wireless network you can skip this step.

When you are finished with the Network Options sub-menu, select <Back> to return to the raspi-config main menu.

Step 3: Localization Options


By default, the Raspberry Pi will assume you are in Great Britain.  If you are not located in Great Britain you will need to tell the Pi where you are in the world.  You can do this by selecting option 4, Localization Options, from the main raspbi-config menu.  You will then be presented with the sub-menu pictured below.


The first optin, I1-Change Locale, will present you with a list of locales. You must first scroll down the menu to find the Great Britain locale, shown as en_GB.UTF-8 UTF-8.  It will be selected with an asterisk, and you must deselect it using the [space bar].  This will remove the asterisk.


You can then continue to scroll through the list to find your own locale.  If you are in the United States you will want to select en_US.UTF-8 UTF-8.  When you have selected your locale with the [space bar] and the asterisk has reappeared, you will need to press [Enter] to continue.

You will then be asked to select the "Default locale for the system environment".  If you are in the US select en_US.UTF-8 by highlighting it with the arrow keys and pressing [Enter].  This concludes this section, and will bring you back to the main raspi-config menu.  Go back to option 4 to return to the Localization sub-menu.

Next you will want to select option I2-Change Timezone.  Simply select your region from the first list, and then select your timezone from the second list.  You will then be returned to the main raspbi-config menu again, but we are not quite done with the Localization Options, so again go back to option 4 to return to the Localization sub-menu.

The last thing we need to do is to select I3-Change Keyboard Layout.  Unless you have a specific keyboard layout you would like to use, select "Generic 105-key (Intl) PC" from the list and press [Enter].  It will then take you to a list entitled Keyboard Layout where all the options are for the UK.  If you are not in the UK, select "other" from this list.

You will then be taken to a list to select your Country of Origin.  If you select "English (US)" you will be presented with yet another list.  If you do not know which layout to select from this list, use the first option: "English (US)" with nothing following it.

This will be followed by even more lists (who knew there were so many keyboard options).  Unless you know specifically which options you want off of these lists, use the following options:

Key to function as AltGr:  <<The default for the keyboard layout>>
Compose key:  <<No compose key>>

When you are finished with Keyboard Layout you will be taken back to the main raspi-config menu, and that's it, you're done with Localization.  If you need to change the Wifi Country you can use option I4 from the Localization sub-menu, but since we just did this under Network Options, there should be no reason to do that here.

Step 4: Interfacing Options


The Interfacing Options sub-menu can be used to turn on various interfaces, such as I2C, UART, or the camera interface.  All of these are optional, and will only be used for specific projects, so I won't cover them here, with one exception, SSH.


If you do not plan on constantly having a keyboard and mouse connected to your Raspberry Pi, you will most likely want to be able to control your Pi over a network using another computer.  The best way to do this is utilizing an SSH connection.  In order to that you need to enable the SSH server on your Pi.  Luckily this is incredibly easy to do.

Simply select option P2-SSH from the Interfacing Options sub-menu.  You will then be asked "Would you like the SSH server to be enabled?", to which you should say "Yes".  That's it, you will now be able to access your Pi remotely.  For instructions on how to do this, check out this tutorial on Remote Access to the Raspberry Pi via SSH.

One more quick note: If you haven't already changed your password to something other than the default, you need to do that now that SSH is enabled.  Otherwise anyone will be able to access your Pi over the network, and you open yourself up to all sorts of malicious activities.  Be safe, and change your password.

Step 5: Expand the File System


There is only one last thing you need to do to complete the initial set-up of your Raspberry Pi: Expand the File System.  This will expand the file system to fill the entire SD card so that you can be sure to have the maximum amount of space available for files.  To do this you will need to select option 7-Advanced Options from the main raspi-config menu.


Under the Advanced Options sub-menu you will want to select option A1-Expand Filesystem.  As soon as you select this, the root partition will be resized, and you  will be presented with a message stating that the filesystem will be enlarged upon the next reboot.  Press enter again and you will be returned to the main raspi-config menu.

And that's it.  Feel free to browse the rest of the menu to see the other options available to you, but at this point you should have completed all the necessary tasks to begin using your Raspberry Pi.  When you are ready select <Finish> at the bottom of the main menu.

Provided you expanded the file system, or some other option that requires a reboot,  you will now be asked if you would like to reboot.  No time like the present, so select <Yes> and wait for the Pi to reboot.

You are now ready to embark on your journey of learning and discovery with the Raspberry Pi.  You can become more familiar with the Linux Command Line.  Learn how to code in Bash script, Python, or any programming language you choose.  Follow tutorials for hundreds of projects, or be creative and design your own.  The sky is the limit.  But most importantly...

Have Fun!

No comments:

Post a Comment