lessons · python · raspberry pi

Lessons on PI – Lesson 2: On the shoulders of giants (apt-get, and git)

screen-shot-2017-02-19-at-8-28-32-am

On the Shoulders of Giants

That phrase, “On the shoulders of giants”, has come to mean, “discovering truth by building on previous discoveries” which just about sums up all of computer science.

screen-shot-2017-02-19-at-5-46-34-am

That idea, is the reason Computers are moving so fast!  When you can reuse the work being done by hundreds of thousands of people daily – it can’t help but change rapidly.  Now, lets get you access to all that work!  Lets learn, “apt-get” and “git”.

Linux comes with apt-get…

Apt-get is a command you will use many times in your Linux explorations.  The “APT” portion of apt-get stands for “Advanced Packaging Tool”.   This puppy handles upgrading the OS, installing new tools, and keeping your OS up-to-date… all for free.  Billions of lines of code are available to download through this simple little command.

Lets get some free stuff…

Free stuff…

In Lesson 1 – you’ve already used it to get access to some free stuff.  Namely games!

Remember this?

moon-buggy-racing-game-for-linux

We installed that through apt-get, like this:

sudo apt-get install moon-buggy -y

Before you get started – we want to make sure you are running from the latest and greatest repositories available.  Lets run these commands:

sudo apt-get upgrade
sudo apt-get update

This will take a while.  After its done – go ahead and reboot to use the latest and greatest.

sudo reboot

So let’s install a few more free things.  Then, while we let apt-get do that, come back here and will talk about these commands.  Run this from the terminal:

sudo apt-get install git vim pacman4console -y

Back?

So let’s break that terminal command down a little.  Sudo stands for “super-user do”.  It turns out that you are a super-user.  Bet you didn’t know that!  By default the pi user is a super-user. Wait a minute… what’s a user?

User?  Account? What’s that?

The term “user” refers to an account or a separate space for one person vs. another.  Imagine you had 100 people who want to share your little raspberry pi.  Now imagine all those people want to create documents on it.

Pretty soon, your little pi would get really messy!  Then what happens when your brother/sister want to change the background – but you don’t!  That would cause arguments!

To avoid all that confusion – operating systems have created the concept of a “user”.  Each separate person gets a “user account”, where their preferences, storage, and environment are special and separate from everyone else’s on that machine.

By default the Raspberry PI Operating System (OS for short) comes with one user.  That user account name is “pi“.  That user is also designated super which means they have complete control over the computer (AND any other account on the machine).

So… when you tell the computer to “super-user do” or sudo you are wielding great power!

he-man

apt-get install

When you issue:

sudo apt-get install git -y

We’ve established the sudo part, now apt-get is the command that does things on software packages.  The next bit is install which is somewhat self explanatory.  It installs the thing that you name after that, in this case “git”.

Git is the software package we’ll use to store our in-progress work, and pull down other people’s in-process work.

The last bit in that command “-y” tells the apt-get command to, “say yes” anytime a question comes up.  In the case of install the apt-get command will often ask, “are you ok with me using up this much disk?” – we know what we are doing, so the answer is always, “yes”. 🙂

Install multiple things at once…

In our command above:

sudo apt-get install git vim pacman4console -y

You’ll notice there are 3 things following the “apt-get” portion of the command.  This is a convenience of apt-get.  It allows you to list off any number of items you’d like it to install.  It isn’t uncommon to see whole piles of packages in that list.  For us, just getting started, we are only install three: git, vim, and pacman4console.

PacMan4Console

This is PacMan4Console:

screen-shot-2017-02-19-at-6-31-32-am

Its a PacMan clone you can play right on the terminal!  Couldn’t leave you without something fun amidst all this hard-core computer science!  Run it by entering:

pacman4console

Then use the arrow keys to avoid the ghosts, eat the pellets and achieve high score!

Git

Git is the gold standard of source code repositories.

screen-shot-2017-02-19-at-6-37-29-am

Soooo THAT’s a mouthful.  Basically, git is your ticket to most of the code that others are working on and sharing across the internet… and you just installed it.  So let’s use it to get some code we’re going to be using in later lessons:

git clone https://github.com/mamacker/kidpi.git

Entering that command goes out to the internet address:

https://github.com/mamacker/kidpi.git

and downloads any software that might be at that location onto your raspberry’s disk.

Checkout what you got:

cd kidpi
ls

You should now see something like:

PaPiRus  forever  lirc  README.md   grove  python

Which is a bunch of new software we’ll play with… again for free!

Try going into the python directory:

cd python

Now run the counting program in there:

python count.py

Boom!  That guy will keep counting forever!!!

When you are tired of watching the computer do something non-stop hit ctrl-c.

Onward!

Continue to the second part of this lesson:

Lessons on PI – Lesson 2(cont.) A little programming…

3 thoughts on “Lessons on PI – Lesson 2: On the shoulders of giants (apt-get, and git)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s