Ubuntu has tons of software available by default in its software repositories. Enable the Universe and Multiverse repositories and you'll find even more. Even so, there are still certain programs (or newer versions of programs), that won't find their way into Ubuntu for a few months, when the newest version is released. Because of this, the PPA (personal package archive) has become a popular method for developers to make their software available to the masses.
The main advantages are pretty obvious. Once added, the PPA enables new versions to be updated along with the rest of the installed "official" software, as long as the author updates the PPA. Plus, for many of us, the idea that we now don't have to compile the new software from source (which might perhaps require us to hunt down exotic libraries not generally available in Ubuntu), is a very good thing.
Adding a PPA is simple. Let's say you want to add the PPA for LibreOffice to your system, as you want to ensure you always have the most up-to-date version installed. To do so, you would first open your Terminal.
Then you would type sudo apt-add-repository ppa:libreoffice/ppa followed by sudo apt-get update and finally sudo apt-get upgrade which will add the PPA, update your software lists then finally upgrade your software (including new versions of LibreOffice from the PPA you just added).
When you add a PPA using this method, a new text file is created in /etc/apt/sources.list.d/ as you can see below.
As you can see, it's easy to end up with half a dozen or more (many more, in some cases!) PPAs. Unfortunately, there's not a built-in method for backing up those text files, or combining them with your standard sources.list, but with a couple of Terminal commands, we can do just that.
First, look again inside the /etc/apt/sources.list.d/ folder. You may notice what appear to be duplicate entries for your PPAs, only some of the files end with .list.save instead of .list as you'd expect.
These are backup files, created automatically when the .list file is accessed. It's perfectly okay to delete those. To do so from the Terminal, first cd to the directory by typing cd /etc/apt/sources.list.d/ into the Terminal.
Then type sudo rm *.save to remove the .save files.
We need to do this as root, as only an administrator can modify this folder.
Once this is done, we'll simply use the cat command. The cat command, by the way, is a powerful tool that simply combines two different documents. In our example, we'll combine the existing master sources.list file with the individual PPA files and create a new list (called files.txt which will go in our Home folder. The command sudo cat /etc/apt/sources.list /etc/apt/sources.list.d/* > ~/lists.txt will do the trick.
What the above command does is first call up the cat program, as root, then tell it to combine the sources.list file, then all the files inside the /etc/apt/sources.list.d/ folder, then (this is the bit after the caret), save them to our Home folder in a file named files.txt.
You will now find, as desired, a single file containing all the information on both the official repositories and all the PPAs you've added in a single file which is quite a bit easier to deal with than a folder full of PPA lists plus the standard sources.list file.
And that's it! An easy method to create a handy backup file for not only your PPA sources files, but your standard Ubuntu sources.list file as well. Just like we wanted.
No comments:
Post a Comment