Linux All-In-One For Dummies
Book image
Explore Book Buy On Amazon

When you know your way around the command line, downloading and installing new software on a computer or BeagleBone running the Linux OS is quite easy and straightforward. The software comes in what are called packages — software programs that can be downloaded from the Internet and installed simply by typing a command in the prompt.

To download and install these packages, you normally use a package manager, which downloads and installs not only the software you requested, but also all other required software, known as dependencies. The Debian distribution uses a package manager called apt.

If you read other literature about the BeagleBone, you may find that you should use the opkg utility as the package manager. Up until recently, the standard distribution used by the BeagleBone was Ångström. Currently, the standard is the Debian distribution, so apt is the way to go.

To manage your software, you need the authorization of the administrator, whom you probably already know as the superuser. Being logged in as root is often considered to be unsafe, as the computer becomes vulnerable not only to its user (who may unwittingly make undesired changes in the file system), but also to malicious software that may have gotten inside.

With that in mind, you can carry out a command with the authorization of the root user without being logged in as such. To do so, type sudo (superuser do) before a command.

In any other situation, if you get an error message telling you that the command you typed can be executed only with the authorization of root, try using sudo before it. Be cautious, though. If the command is telling you that it needs the authorization of root, it’s probably because something serious is involved!

First and foremost, you have to update the list of available package versions that your package manager is aware of. (The package manager keeps such a list in the BeagleBone’s file system.) Type the following command:

sudo apt-get update

You need to be connected to the Internet for this command to work. Text scrolls by after you type the command, giving information about the newest listings.

Next, you should update the software, which you can achieve by commanding apt to upgrade. This command upgrades all the packages you’ve installed to their most recent versions:

sudo apt-get upgrade

In terms of wording, the difference between updating and upgrading is subtle, but what they do is quite different (even though they’re usually done together). sudo apt-get update updates the list of available package versions but doesn’t install or upgrade any of them, whereas sudo apt-get upgrade updates the packages themselves, checking the list to do so. For that reason, you should always run update before upgrade.

Installing software

To install a package for which you already know the name, you have to type the following command:

sudo apt-get install <desired application>

To see how this process works, use the following command to install the Midnight Commander application, which is a visual file manager:

sudo apt-get install mc

This command downloads the package from the Internet and installs it, as well as any dependencies it requires to work properly.

Always run sudo apt-get update before installing software.

Running software

To run programs directly from the prompt, simply type their names, as shown in the following command and figure:

debian@beaglebone:~$ mc

Updating software

You can update the latest versions of your software by typing the upgrade command:

sudo apt-get upgrade

Generally, though, you want to update the list of available package versions before you upgrade to ensure that apt gets you the most recent updates for your installed software.

Instead of getting updates and upgrades by writing the commands separately, you can write them both in a single line as follows:

sudo apt-get update && sudo apt-get upgrade

The && is a binary operator that means AND. The AND operator is commonly used in programming to test for multiple conditions. For now, keep in mind that its use ensures that the second command executes only if the first succeeds. If your update fails for some reason (maybe because you lack an Internet connection), the system won’t even attempt to upgrade.

This process (specifically, the upgrading part) can take a very long time, which can be troublesome if you want to update a single application. Fortunately, you can do so by typing the install command again, remembering to update the list of available package versions first:

sudo apt-get update && sudo apt-get install mc

This command doesn’t install the software all over again. Instead, the package manager first checks for updates and installs them. If updates aren’t available, the package manager displays a message that the software is already up to date.

Removing software

To remove software from your BeagleBone, you resort once more to the apt package manager. Here’s an example:

sudo apt-get remove mc

This command, however, leaves behind files that are somehow related to the software, such as configuration files and logs. If you don’t intend to use those files in any way, you can remove everything by using purge:

sudo apt-get purge mc

You can also direct the system to check for unnecessary packages and/or files and remove them automatically.

The package manager downloads and installs not only the requested package, but also any other packages that it may depend on. Thus, if you delete some software, its dependencies may stay behind. The apt package manager deems the dependencies unnecessary and deletes them automatically when you issue the following command:

sudo apt-get autoremove

Don’t fret about giving so much power to the package manager. Before deletion, you see a list of the packages that will be removed, and you’re prompted to press Y to confirm that you do want those packages removed. You also see how much space will be freed.

To remove all files that are undoubtedly unnecessary, you can type the following command:

sudo apt-get clean

These files are usually installation files. They remain on your computer after the installation of a program, even though they’re no longer needed. Removing them isn’t an issue.

It's recommended that you not remove any package that you didn’t install yourself unless you’re absolutely certain that you know what it’s for. It may be a necessary package that comes with the Linux OS, and removing it may lead to a system crash.

Seeing what’s installed on your BeagleBone

To see a list of installed packages on your BeagleBone, type the following command:

dpkg --list

Note that this command doesn’t require root authorization. After all, you aren’t messing around with the software; you’re just listing it. Consequently, it’s not necessary to use sudo.

To see whether a specific package is installed, as well as a more detailed description about it, you can use the following command:

dpkg --status <nameOfThePackage>

About This Article

This article can be found in the category: