Today, my uncle gave me a raspberry pi. I’m so excited! I’ve used a Lego Mindstorms and have coded a little bit in python and HTML. My uncle is a software engineer and gave me some quick lessons. One thing he told me is to practice using the raspberry pi through the linux command prompt by typing in commands and typing programs using an editor called “vi”. He said that all of the software engineers at his company use vi and that it’s one of the first questions they ask in an interview, “Do you know how to use vi?”
He also told me about something important in programming through the raspberry pi called “permissions.” As a user, I don’t have permission to access certain things like the pins on the raspbpi (short for raspberry pi). So, if I write a program to light up an LED, I’ll get an error that I don’t have permission to do that. So, I have to use a command called “sudo”. “sudo” has permission to run everything. So, if instead of typing “./program” the normal way to run a program, I have to type “sudo ./program”. But I have to be careful with this because sudo has a lot of power. So, every time I run something through sudo, it asks me for my password to remind me that I’m doing something that could be dangerous.
He showed me how to open vi simply by typing “vi” at the unix command prompt. I later learned that there are two modes in vi, command mode and insert mode. Command mode is for doing things like saving a file and quitting vi. All of the commands begin with a colon. If I want to save a file, I type “:w” or if I want to quit vi, I type “:q” or if I want to quit without saving, I type “:q!”. If I want to “save as” I type “:w newfilename”. These are all of the commands I’ve needed so far. To get into insert mode, I just hit the “i” button. Now, I can type programs. My uncle set up Unix so that I can program in python, java, or c++. My dad and I have read a little bit about python already so I chose that one. After typing a program (“Hello World!” of course), I hit escape to go back to command mode to save and quit vi.
Now that I’m back in Unix, I can try to run my program. Because I’m programming in python, I just type “python filename.py”. This is only if I saved the file as “filename.py”. If I did anything wrong, there will be an error message and it will show me exactly where the mistake is. Then I have to go back into vi and fix it.
I learned some other interesting things about Unix from my uncle. If I want to change directories (folders in windows or mac), I type in “cd foldername”. If I want to see what is in a directory, I type “ls” (that’s lowercase L and S). There is a color code that tells me if I’m looking at a directory, a file, or a program. Also, if I don’t want to retype a command over and over, I can use the up arrow to go back to a command that I’ve typed recently. Or, I can type “history” and see the last 100 or more instructions that I’ve typed in Unix. That’s very helpful because I couldn’t remember some of the things that my uncle typed and I could just see the history and copy it.
He also showed me that I can connect the raspbpi to the TV or I can connect to it from my laptop using SSH. My dad helped me set it up using a program called PuTTY that is free online. He looked up a number called the IP address and we just type it in and connect. Then I can type on the laptop from anywhere in the house. When connected to the TV, I use a wireless mouse and keyboard. The raspbpi also connects to the internet.
If you don’t know what a Raspberry Pi is, watch this video or visit http://raspberrypi.org