Definition of Linux Repository
Going by the literal meaning of repository, it is defined as a location where “something” is found in significant quantities and when the meaning is extended in computing, it is defined as a central location where data is stored as managed. Now, for the purpose of Linux, a repository is a location from where the Linux system retrieves and installs updates and applications related to the Operating system. The repository is nothing, but a collection of software, and this collection is hosted on a remote server and is downloaded and installed for either installing or updating software packages on the Linux system. In this article, we will talk about the standard and non-standard repositories, but before that let us peep into the syntax first.
Syntax:
Before we learn on what goes inside repository addition on Linux and what are the different segments of repositories, we in this section would like to look at syntaxes of different possibilities of repositories in Linux.
- Adding a non-standard repository
sudo apt-add-repository <repository name>
- Removing a non-standard repository
sudo apt-add-repository -r <repository name>
- Showing repository keys
sudo apt-key list
- Deleting repository keys
sudo apt-key "<Key number>"
OR
sudo apt-key "<last eight characters of the key>"
- Updating repositories
apt-get update
How Repository works in Linux?
Now that we are aware of the Linux syntax and different use cases of the repositories, it is imperative for us to know about the repositories in detail and the way of working of repository.
Repositories are a collection of thousands of programs and these programs are capable of providing a high level of security. With these repositories getting updated every now and then, thorough testing and built compatibility is tested for so that the distribution and updating of the version is seamless. The updates occur with no “breakage” of the operating system.
Now that there is a considerable understanding of what repositories are let us look at some classification of these repositories in one of the most famous Linux distribution, Ubuntu. The reason we call it the famous distribution is because of the reachability it has provided in the short time of distribution. If we can understand the classification, it will be easier for us to correlate, and extrapolate is for any other distribution or repository. The software in Ubuntu’s repository is divided into 4 categories:
Main: Some of Ubuntu’s software are free ones, and even can be redistributed and has full support from Ubuntu’s team. The reason the software which falls into this category is chosen is that they are considered as the most important ones along with the ubuntu’s security and distribution team are willing to support and expand the features and usability of the same. Some of these set of software is by default installed in the system.
Restricted: These are those “small” set of tools which help to install of Ubuntu and its free applications efficiently. These are the proprietary drivers that are kept in the restricted component and complete support by Ubuntu developers are not possible as they are not able to fix them by own and work with vendors on fixing the issues. Although Linux or Ubuntu promotes free open source software, there are some as already mentioned “small” set.
Universe: These sets of software are built from a range of public sources and the snapshot of these categories houses almost every other software from the free, open-source Linux world. Every piece of open-source software would be available here, but with a pinch of salt that all updates, for example, security updates, might not be present at regular intervals. Having said that the updates will surely be made available when it is done for the entire community. With this small difference between Main and Universe, the set of software are interchangeable in terms of places. For example, the software can move from Universe to main if backed by people who are ready to maintain, and in contrast, the software can move from Main to the universe if the support for the software is fully gone.
Multiverse: These are again some small set of software which do not meet components maintenance policy and norms and the onus lies in the hands of the user to verify if the licensing terms have complied.
Now it is time for us to look at the working of different syntax in the topic of repositories before jumping on to the examples of each.
- Adding a non-standard repository
sudo apt-add-repository <repository name>
Here, at first, we add sudo to make the command run in superuser or admin mode. The apt-add-repository invokes the command to add the repository to the Linux and finally, the <repository name> needs to be added to the corresponding name of the repository which you like to install.
- Removing a non-standard repository
sudo apt-add-repository -r <repository name>
Here again, at first, we add sudo to make the command run in superuser or admin mode. The apt-add-repository invokes the command to add a repository to the Linux, the -r option lets the command know that we would need to remove a repository, and finally the <repository name> needs to be added the corresponding name of the repository which you like to install.
- Showing all repository keys
sudo apt-key list
Again here, we add sudo to make the command run in superuser or admin mode. The apt-key invokes the command to add repository keys to the Linux and finally the list prints all the keys present in the Linux.
- Deleting repository keys
sudo apt-key del "<Key number>"
OR
sudo apt-key del "<last eight characters of the key>"
Like showing all repository keys, adding a del option invokes that command should now delete the given key which is denoted by <Key number>, which essentially is the entire key or alternatively <last eight characters of the key> which just takes last eight characters of the key.
- Updating repositories
sudo apt-get update
This command will allow updating of all repositories which are installed under the Linux system, where the update is the keyword that will invoke the action.
Examples
Lets us discuss examples of Linux Repository.
Example #1
Syntax:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
sudo add-apt-repository 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse'
Output:
After adding of the repository:
Example #2
Syntax:
sudo add-apt-repository -r 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse'
Output:
sources.list file before removal
sources.list file after removal
Example #3
Syntax:
sudo apt-key list
Output:
Example #4
Syntax:
sudo apt-key del E52529D4
Output:
Before deletion.
After deletion.
Example #5
Syntax:
sudo apt-get update
Output:
Conclusion
In this article, we have gone through all commonly used methods of how repositories are used. This option of repositories is the crucial part of easiness in working with Linux so that one doesn’t have to reinvent the wheel in an open-source platform.
Recommended Articles
We hope that this EDUCBA information on “Linux Repository” was beneficial to you. You can view EDUCBA’s recommended articles for more information.