Learn basic package operations on Debian-based distributions
Your client just got a new Ubuntu server. He already installed Apache2, but decided to use Nginx 1.5 instead.
He already tried to add the nginx/development repository to get the Nginx version 1.5, but
apt-get install nginx didn't work.
He wants you to fix this and a few other things:
- install Nginx 1.5
- remove Apache2 completely, including all files that were installed
- he messed up /etc/crontab. Please make a backup of this file to /etc/crontab.backup and install the original file that came with Ubuntu
- to prevent the system to ask which editor should be used, please remove
- The first boot will take a few minutes to prepare
To install packages on Debian-based distributions you'll use
Occasionally you'll stumble across
aptitude as well - but you'll probably use
apt most of the time.
How packages work is also one main difference between different Linux distributions. Debian distributions uses the Debian Packages - file extension
You won't find
.deb files on other distributions than Debian-based systems since they use a different package format.
CentOS or Red Hat Enterprise Linux, for example, uses the RPM package format - to install these you'll use yum.
Please see listed external resources to learn about
using third-party repositories
It is important to remember that software must be developed and maintained by people or companies and that it must come from somewhere.
In the case of Linux, we call the source of packages Repositories(short: Repo). Repositories often not only contain the finished tool, but also the source code, a bug tracker(a place to collect and manage software bugs) or wikis.
A repository is just a URL that Ubuntu/the package manager uses as a source for the tool. The repo maintainer will always distribute the latest updates via the Repo - by checking the URL via an e.g.
apt update, you always get notified about new versions.
The app store you find on modern distributions is just a graphical user interface to interact with these repositories and are just a friendlier version of
To make it easier to get the software, Linux distributions include a collection of repositories from the beginning. These repos often include system tools and very popular tools like the Apache web server.
Because all distributions have their own quirks and features, the included repositories are often maintained by the maintainer of the distribution itself. In the case of Ubuntu, it's the company Canonical. They maintain their repo at packages.ubuntu.com.
Since Ubuntu only includes its own repository, it also acts as a security feature. As long as Canonical is under the control of the repository, a freshly installed Ubuntu can only install what Canonical is distributing. They will also fix bugs that are specific to the distribution - but keep in mind that they usually not the original inventor of these tools. The original source is called the upstream.
Launchpad.net is a service to create public repositories for everyone. To install a tool from Launchpad, you need to add the tools repository URL to your system first.
The popular editor nano was developed in the '90s as pico, a clone was developed and called nano.
You'll find the source code at nano's website: git.savannah.gnu.org/cgit/nano.git/log/ - but you can't just start nano from the raw text file, right?!
This is where a package repository comes in to play - but first, you need to know that Ubuntu is Debian-based and uses Debian packages as their upstream. So, Canonical reuses Debian packages and may add/modify features to it.
Debian includes nano in a core repository - some of nano's developers are also maintainer for the package in the Debian repository. They make sure it always includes the latest changes from the original upstream(nano's own, official git repository). Canonical then incorporates these changes into the Ubuntu package.
This is also why some people are not happy about cooperations using their open source code. Companies like Canonical or RedHat earn money with free, open source code - and sometimes fix bugs or add features to the code in their repository, but doesn't add them back to the original upstream. This is a whole topic by itself and includes other important topics like software licenses and open source culture.
This example also shows why it can have negative side effects to use repositories, but also why it's better to use them anyway:
- in case a repository is unmaintained, you won't get updates of the software
- especially important when using not so popular tools that don't have a big and active community
- in case the development is too fast, the repository maintainer may can't keep up and provide outdated versions in the repository
- when a tool is installed manually - and not through a repository - you do need to check for updates yourself and can't use apt update
It's usually better to use official or community supported repositories then manually checking for updates.
remove installed tools
Removing tools is very similar to installing them - you probably find all you need in the first section: installing tools.
It is important to check the output while removing a tool. You'll often find information about directories or files that didn't get deleted. These files often hold configuration files or files that were modified by the user - the uninstaller then warns you and helps you to keep these files. They must be either removed by hand or with a special option while uninstalling.
Another note: When installing a tool, it often installs additional tools as a dependency. Sometimes the installer will also check for installed tools and add configuration files to the existing, already installed tools. To completely remove all configuration files check the output while removing and check out
While it's not hurting the system to include unused configuration files or unused tools, a clean system is always easier to work with. Imagine troubleshooting a configuration file, you found on the system, only to find out that it's just a leftover file from 4 years ago.
restore configuration files
While some operations are almost unrecoverable, changing or deleting files that came with a tool is not.
When installing tools via packages, the .deb file contains everything necessary to install and run it. Since your Linux system usually stores the source files on the hard drive, you don't even need to download the .deb file again.
Check out the external resources to learn more about the .deb file and how to recover configuration files: