DEV Community

loading...
Cover image for Adding repositories to sources.list.d manually

Adding repositories to sources.list.d manually

Talles L
A Brazilian software developer ๐Ÿ‡ง๐Ÿ‡ท that loves to play video-games ๐ŸŽฎ, tries it best to be active on GitHub ๐Ÿ’ป, and sometimes writes here on DEV ๐Ÿ“„
ใƒปUpdated on ใƒป2 min read

It's pretty common to find instructions for adding an deb repository source as a shell script. They normally append stuff to /etc/apt/sources.list, while I prefer creating a separate file for each repo on /etc/apt/sources.list.d.

Here's how I do:

1. Create a /etc/apt/sources.list.d/{repo name}.list file with its content being the repository source (some at the end of this post):

sudo vim /etc/apt/sources.list.d/{repo name}.list
Enter fullscreen mode Exit fullscreen mode

2. Download the repo GPG key (as text):

curl {gpg key url} > {repo name}
Enter fullscreen mode Exit fullscreen mode

3. Convert it to a .gpg (binary):

gpg --dearmor {repo name}
Enter fullscreen mode Exit fullscreen mode

4. Delete the original file and move the .gpg one to /etc/apt/trusted.gpg.d/:

rm {repo name} && sudo mv {repo name}.gpg /etc/apt/trusted.gpg.d/
Enter fullscreen mode Exit fullscreen mode

Now you can sudo apt update and sudo apt install {your package}.

Here's some of my repos (Ubuntu 20.04):

Discussion (0)