You are on page 1of 14

D E VO P S AU TO M AT E I N F R A

LEARNING
Most Trending and Quality DevOps Cloud Automation
tutorials, guides and learning
SKIP TO CONTENT

• HOME
• BLOG
• DEVOPS ENGINEER
• HIRE ME
• TWITTER
• REDDIT
• DEVOPS NEWS

Ultimate Guide on how to add apt-


repository and PPA repositories and
working with ubuntu repository
APRIL 14, 2021 / AUTOMATEINFRA

As a Linux administrator it is very important to know how you are managing


your applications & Software’s. Every command and every installation of
packages require critical attention before executing it.

So In this Ultimate guide we will learn everything you should know about ubuntu
repositories , how to add apt-repository & PPA repositories and working with
ubuntu repository and apt commands.

Table of Content
1. What is ubuntu repository?
2. How to add a ubuntu repository?
3. Manually Adding apt-repository in ubuntu
4. Adding PPA Repositories
5. Working with Ubuntu repositories
6. How apt or apt-get command work with Ubuntu Repository
7. Conclusion
What is ubuntu repository?
APT repository is a network shared server or a local directory containing deb
packages and metadata files that are readable by the APT tools. When installing
packages using the Ubuntu Software Center or the command line utilities such
as apt or apt-get the packages are downloaded from one or more apt software
repositories.
On Ubuntu and all other Debian based distributions, the apt software
repositories are defined in the /etc/apt/sources.list file or in separate files
under the /etc/apt/sources.list.d/ directory.
The names of the repository files inside the /etc/apt/sources.list.d/ directory
must end with .list.
How to add apt-repository in ubuntu ?
add-apt-repository is basically a python script that helps in addition of
repositories in ubuntu.
Lets take a example to add a mongodb repository in ubuntu machine
• add-apt-repository utility is included in software-properties-
common package.
sudo apt update
sudo apt install software-properties-common

• Import the repository public key by running apt-key command


sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv
9DA31620334BD75D9DCB49F368818C72E52529D4

• Add the MongoDB repository using the command below.


sudo add-apt-repository 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu
bionic/mongodb-org/4.0 multiverse'

Verified in /etc/apt/source.list repository has been added succesfully


Manually Adding apt-repository in ubuntu
To add repositories manually in ubuntu edit the /etc/apt/sources.list file and
add the apt repository line to the file.
To add the repository open the sources.list file with your favorite editor
1 sudo vi /etc/apt/sources.list
Add the repository line to the end of the file:

sudo add-apt-repository 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu


bionic/mongodb-org/4.0 multiverse'
• If required to add manually public key for which you can
use wget or curl command
Adding PPA Repositories
Personal Package Archives (PPA) allows you to upload Ubuntu source packages
that are built and published with Launchpad as an apt repository.

When you add a PPA repository the add-apt-repository command creates a new
file under the /etc/apt/sources.list.d/ directory.
Lets take a example of Addition of ansible PPA repository in ubuntu
machine
• PPA utility is included in software-properties-common package
similar to add-apt-repository
sudo apt update
sudo apt install software-properties-common
• Add PPA ansible Repository in the system.
1sudo apt-add-repository --yes --update ppa:ansible/ansible
2# PPA is Personal Package Archive

• Lets check the directory /etc/apt/sources.list.d/ has ansible PPA


repository

Working with Ubuntu repositories


Repositories in ubuntu machine are basically file servers or network shares
under which it has lot of packages , it could be .deb packages or files which are
readable by apt or apt-get command.
/etc/apt/sources.list or

/etc/apt/sources.list.d

What does sources.list and sources.list.d contains ?


• Software in Ubuntu’s repository is divided into four categories or
components – main, restricted, universe and multiverse.
• main: contains applications that are free software that are
fully supported by ubuntu.
• multiverse: contains software’s that are not free that
requires license.
• restricted: only to promote free software and ubuntu
team cannot fix it & then provide it back to author if any
issues are found.
• universe: They have all the possible software’s which are
free and open sourced but ubuntu don’t provide regular
patch guarantee.
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ bionic main restricted
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
• deb or deb-src are either .deb packages or source code
• http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ is the repository URL
• bionic , bionic-security , xenial are distributions code name.
• main, restricted, universe and multiverse are repository categories.
How apt or apt-get command work with Ubuntu Repository
APT stands for Advanced Packaging Tool which performs functions such as
installation of new software packages, upgrade of existing software packages,
updating of the package list index, and even upgrading the entire Ubuntu system
by connecting with repositories stored
under /etc/apt/sources.list or /etc/apt/source.list.d/
Let us see an example of how apt command works with ubuntu
repositories.
• Install below three packages
apt install curl

apt install wget

apt install telnet


• You will notice that all the above packages are already up to date
and latest
• Now run the apt update command to update the repositories. apt
command contains three types of lines.
• Hit: If there is no change in package version from the
previous version
• Ign: It means package is being ignored.
• Get: It means it has a new version available. It will
download the information about the version (not the
package itself). You can see that there is download
information (size in kb) with the ‘get’ line in the
screenshot above.
apt update
• After completion of command it provides the details if upgrade is
required by any package or not. In our case it shows 37 packages can
be upgraded. Lets see the list of packages which can be upgraded by
running the following command.
apt list --upgradable
You can either upgrade a single package or upgrade all packages together.
To upgrade a single package use : apt install <package-name>
To upgrade all packages use : apt upgrade
• Lets just update the curl package by running the apt
install command and verify
apt install curl
• You will notice that updating curl command upgraded 2 packages
which were related to curl and rest of 35 are still not upgraded.

• Now, lets upgrade rest of the 35 packages together by running apt


upgrade command.
apt upgrade

• Lets run apt update command again to verify if ubuntu still requires
any software to be upgrade. Command output should look like “All
packages are up to date”
apt update
Conclusion
In this tutorial we learnt everything about ubuntu repositories and how to add
various repositories and how to work with them . Finally we saw how apt
command works with ubuntu repositories.

This Ultimate Guide will give you a very strong understanding of package
management which is most important thing for a Linux administrator. Hope you
liked this tutorial and was helpful. Please share.

• LinkedIn
Share this:

• Share

• More

Loading...

Related

How to Install Ansible and Run ansible-playbooks on Ubuntu 18.04 LTS


March 25, 2021
In "Ansible"
How to Install PowerShell 7.1.3 on Ubuntu and Windows Machine Step by Step.
April 11, 2021
In "Powershell"

How to Install Docker ubuntu step by step


March 19, 2021
In "Docker"
Ubuntu Repository

APT SOFTWARE REPOSITORIES, APT UPDATE, APT UPGRADE, APT-ADD-


REPOSITORY, PPA, UBUNTU REPOSITORY

Post navigation
← How to Connect Windows to Linux and Linux to Windows using PowerShell 7 SSH Remoting ( PS
Remoting Over SSH)
How to Launch AWS Redshift Cluster using AWS Management Console in Amazon account. →

Leave a Reply
The Most Trending, Quality DevOps Cloud articles, Automation guides, series, News,
Podcasts, and videos. Easy and happy Learning! – Founder (shanky)
Search
Search for:

CATEGORIES
• Ansible (5)

• Apache (1)
• AUTOMATION (8)
• AWS (18)
• AWS EBS (1)
• AWS EC2 (2)
• AWS EKS (1)
• AWS IAM (4)
• AWS Keys (1)
• aws rds (1)
• AWS S3 (2)
• Bash Scripting (1)
• CLOUD (2)
• Computer (1)
• DEVOPS (5)
• DevOps News (1)
• Docker (6)
• Elastic Block Store (1)
• Git (2)
• GitLab (1)
• Grafana (1)
• Groovy (1)
• Jenkins (1)
• kubernetes (8)
• LINUX (5)
• Monitoring (1)
• Node.js (1)
• Powershell (3)
• PowerShell Remoting (2)
• Prometheus (1)
• Python (5)
• Python3 (2)
• Shell scripting (1)
• Solr (1)
• SSH (1)
• Terraform (16)
• TOMCAT (1)
• Ubuntu Repository (1)
• Windows (2)
Advertisements

FOLLOW US
• LinkedIn


Advertisements
Advertisements
Advertisements
Advertisements

ARCHIVES
Archives

BLOG STATS
• 204,263
Advertisements hits
Advertisements

TRANSLATE

Powered by Translate

FOLLOW ME ON TWITTER
Advertisements
Advertisements
TOP POSTS & PAGES

How to create Secrets in AWS Secrets Manager using Terraform in Amazon account.

How to Install Apache tomcat using Ansible.

How to Launch AWS Elastic beanstalk using Terraform

Windows Boot Process Step by Step

How to Connect two Linux machines using SSH keys

How to Setup AWS WAF and Web ACL using Terraform on Amazon Cloud

Search
Search for:

Automateinfra.com Ⓒ 2021-2022 MOST TRENDING BLOG


• Follow


Close and accept
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

You might also like