Powering up Raspberry Pi Zero with Linux
After completing the tasks discussed in Chapter 1, Getting Started with Raspberry Pi Zero, you'll have a working Raspberry Pi Zero that is running a version of Linux called Raspbian. So, power up your Raspberry Pi Zero and log in using a valid username and password. If you are going to log in remotely through SSH or vncserver, go ahead and establish the connection now. First, you'll take a quick tour of Linux. This will not be extensive, but you will just walk through some of the basic commands.
Once you have logged in, open up a terminal window. If you are logging in using a keyboard, mouse, and monitor, or using vncserver, you'll find the terminal by selecting the Terminal application on icon set selection at the top of the screen, as shown in the following screenshot:
If you are using SSH, you will already be in the terminal emulator program. Either way, the terminal should look something similar to the following screenshot:
Your cursor is at the Command Prompt. Unlike Microsoft Windows or Mac's OS, with Linux, most of our work will be done by actually typing commands in the command line. So, let's try a few commands. When you type ls
, you should be able to see the result similar to the following screenshot:
In Linux, the ls
command lists all the files and directories in our current directory. You can tell the different file types and directories apart because they are normally in different colors. You can also use ls –l
to see more information about the files.
You can move around the directory structure by issuing the cd
(change directory) command. For example, if you want to see what is in the Desktop
directory, type cd
Desktop
. If you issue the ls
command now, you should see something similar to the following screenshot:
This directory is empty; it doesn't have any files. The cd
command changes the directory. You could have typed cd /home/pi/Desktop
and received exactly the same result; this is because you were in the /home/pi
directory, which is the directory where you always start when you first log in to the system.
If you ever want to see which directory you are in, simply type pwd
, which stands for present working directory. If you do that, you will get the result, which is similar to the following screenshot:
The result of running the pwd
command is /home/pi/Desktop
. Now, you can use two different shortcuts to navigate back to the default directory. The first is to type cd ..
on the terminal; this will take you to the directory just above the current directory in the hierarchy. Then type pwd
; you should see the following screenshot as a result:
The other way to get back to the home directory is by typing cd ~
; this will always return you to your home directory. You can also type cd
to return to your home directory. If you were to do this from the Desktop
directory and then type pwd
, you would see the following screenshot as the result:
You can go to a specific directory using its entire pathname. In this case, if you want to go to the /home/pi/Desktop
directory from anywhere in the filesystem, simply type cd /home/pi/Desktop
.
There are a number of other Linux commands that you might find useful as you program. The following is a table with some of the most useful commands:
Now, you can play around with the commands and look at your system and the files that are available to you. But, be careful! Linux is not like Windows; the default behavior is to not warn you if you try to delete or replace a file.