Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
BeagleBone Black Cookbook

You're reading from   BeagleBone Black Cookbook Over 60 recipes and solutions for inventors, makers, and budding engineers to create projects using the BeagleBone Black

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher Packt
ISBN-13 9781783982929
Length 346 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Setting Up for the First Time FREE CHAPTER 2. Basic Programming Recipes 3. Physical Computing Recipes Using JavaScript, the BoneScript Library, and Python 4. Exploring GNU/Linux Recipes Using Bash, Autotools, Debugger, and systemd 5. Basic Programming Recipes with the Linux Kernel 6. Run Faster, Run Real Time 7. Applied Recipes – Sound, Picture, and Video 8. The Internet of Things 9. The Black in Outer Space Index

Package management – Installing packages using apt-get

If you are a newcomer on Linux, you will find that managing software on your BBB is a very different experience from the one on your Windows or Mac box. Linux distributions have a very different sensibility when it comes to installing and supervising your software.

In some ways, it is akin to what your smart phone universe is like: you go to a centralized place (Google Play, App Store, and so on) and download a vetted application.

Of course, there are huge differences in Land o' Linux. Firstly, everything is free. Secondly, everything is (mostly) open source. Thirdly, pieces of your package—dependencies, libraries, and so on—that evolve and improve are treated as separate entities that only need to be conjoined when you are ready to actually install a piece of software.

This means that you're always getting the freshest, most stable build. Whereas in Closed Source Land, executables are built to be self-contained. Any new module or better library that is built after the binary was compiled….well, too bad. You will have to wait for the next release, whenever that might be. And then you have to pay for the upgrade.

Software applications for Linux are referred to as packages. Henceforth, we will mainly use the term package in lieu of application. In this section, we will learn the basics of package management through the following topics:

  • Updating packages
  • Upgrading packages
  • Installing packages

Note

These recipes assume that you have internet connectivity working via any of the methods explained in the earlier Connectivity section.

For our recipes throughout this book, we will principally use the apt-get command for package management. Although there are other methods, apt-get is the easiest and most common way to handle packages for a beginner.

Getting ready

Use the following steps to install packages:

  1. Updating packages: Before actually installing new software in Linux, it's best practice to ensure that you have downloaded the most current versions of your local package lists along with information about their dependencies. You execute one of the most common commands in the Linux repertoire:
    $ sudo apt-get update
    

    As a result of this command, we get a resynchronized package index file that is targeted not only at your specific Linux distributions, but your hardware environment as well. For the BBB, this means that your package manager knows to only grab packages that are Debian-savvy and compatible with the Arm board architecture.

  2. Upgrading packages: Next, you want to grab and upgrade to new versions of the packages already installed on your BBB, which the apt-get update will presumably have chronicled, through the following command:
    $ sudo apt-get upgrade
    
  3. Finally, you get to install your new whizzy tool or app! Use this command:
    $ sudo apt-get install pkg_name
    

How to do it…

Let's do a real package, though, one that we will be using in a later chapter. For our recipes focused on debugging in Chapter 3, Physical Computing Recipes Using JavaScript, the BoneScript Library, and Python, we will use a tool called gdb, also known as GNU Debugger, which is a standard tool in the Linux arsenal thus:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install gdb

Once you've installed the pretty package on your BBB, it's useful—and often interesting—to take a peek inside. So, another apt-get variant gives you some interesting insight:

$ sudo apt-cache show package-name

In our case, this would be as follows:

$ sudo apt-cache show gdb
Package: gdb
Version: 7.4.1+dfsg-0.1
Installed-Size: 5192
Maintainer: Hector Oron <zumbi@debian.org>
Architecture: armhf
Depends: libc6 (>= 2.13-28), libexpat1 (>= 2.0.1), libgcc1 (>= 1:4.4.0), libncurses5 (>= 5.5-5~), libpython2.7 (>= 2.7), libreadline6 (>= 6.0), libtinfo5, zlib1g (>= 1:1.2.0), gdbserver
Suggests: gdb-doc
Description-en: The GNU Debugger
 GDB is a source-level debugger, capable of breaking programs at
 any specific line, displaying variable values, and determining
 where errors occurred. Currently, gdb supports C, C++, D,
 Objective-C, Fortran, Java, OpenCL C, Pascal, assembly, Modula-2,
 and Ada. A must-have for any serious programmer.
Homepage: http://www.gnu.org/s/gdb/
Description-md5: 8132571fab028a898d029eecd88e571e

See also

To list all installed packages, enter:

dpkg --list

Alternatively, you can use this command:

dpkg --list | less

You can also run the following command:

dpkg --list | grep -i 'http'

Note the grep option as part of the command string. One of the most popular commands on Linux, grep is a powerful search mechanism to find a particular file, a directory, a pattern or chunk of code.

You have been reading a chapter from
BeagleBone Black Cookbook
Published in: Nov 2015
Publisher: Packt
ISBN-13: 9781783982929
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image