Ubuntu – How to get a list of all repositories and PPAs from the command line into an install script

add-apt-repositorycommand linepparepositoryscripts

I know how to list all packages installed on my system.

But how could I get a list of all repositories and PPA's into a script that I can run on a new machine to replicate the repository setup including the keys?

I know I can look into /etc/apt/sources.list and /etc/apt/sources.list.d, but I'm looking for a way to generate a script that executes all apt-add-repository commands on a new system (that sorts out getting all keys).

Any ideas?

Best Answer

You can show everything with:

grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*