Add or remove repository using command-line utility.
Inspect what would be done when you add specific archive.
$ sudo add-apt-repository --dry-run --sourceslist "deb http://openresty.org/package/debian $(lsb_release --short --codename) openresty"
Repository: 'deb http://openresty.org/package/debian jammy openresty' Description: Archive for codename: jammy components: openresty More info: http://openresty.org/package/debian Adding repository. DRY-RUN mode: no modifications will be made Adding deb entry to /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list
Inspect what would be done when you add specific archive URI, component including source packages.
$ sudo add-apt-repository --dry-run --enable-source --uri http://openresty.org/package/debian --component openresty
Repository: 'deb http://openresty.org/package/debian jammy openresty' Description: Archive for codename: jammy components: openresty More info: http://openresty.org/package/debian Adding repository. DRY-RUN mode: no modifications will be made Adding deb entry to /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Adding deb-src entry to /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list
Inspect repository file.
$ cat /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list
deb http://openresty.org/package/debian jammy openresty # deb-src http://openresty.org/package/debian jammy openresty
Add repository, but do not update the package cache.
$ sudo add-apt-repository --yes --no-update --uri http://openresty.org/package/debian --component openresty
Repository: 'deb http://openresty.org/package/debian jammy openresty' Description: Archive for codename: jammy components: openresty More info: http://openresty.org/package/debian Adding repository. Adding deb entry to /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list
List configured repositories.
$ sudo add-apt-repository --list
deb http://archive.ubuntu.com/ubuntu/ jammy universe restricted multiverse main deb http://archive.ubuntu.com/ubuntu/ jammy-updates universe restricted multiverse main deb http://archive.ubuntu.com/ubuntu/ jammy-security universe restricted multiverse main deb http://archive.ubuntu.com/ubuntu/ jammy-backports universe restricted multiverse main deb http://openresty.org/package/debian jammy openresty
Inspect what would be done when you try to remove repository.
$ sudo add-apt-repository --dry-run --remove --uri http://openresty.org/package/debian --component openresty
Repository: 'deb http://openresty.org/package/debian jammy openresty' Description: Archive for codename: jammy components: openresty More info: http://openresty.org/package/debian Removing repository. DRY-RUN mode: no modifications will be made Disabling deb entry in /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Removing disabled deb entry from /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Removing disabled deb-src entry from /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list
Remove repository.
$ sudo add-apt-repository --yes --remove --uri http://openresty.org/package/debian --component openresty
Repository: 'deb http://openresty.org/package/debian jammy openresty' Description: Archive for codename: jammy components: openresty More info: http://openresty.org/package/debian Removing repository. Disabling deb entry in /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Removing disabled deb entry from /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Removing disabled deb-src entry from /etc/apt/sources.list.d/archive_uri-http_openresty_org_package_debian-jammy.list Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease Hit:2 http://archive.canonical.com/ubuntu jammy InRelease Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease Hit:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Fetched 5542 B in 20s (271 B/s) Reading package lists... Done
So, use –sourcelist
parameter when you want to be strict about sources.list
line, as antry added using –uri
and –component
parameters will be tied to the current release.
Using –no-update
parameter would not update the package cache after each operation, so can be handy when processing multiple entries as you can simply defer this step.