Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems to me that some files I write to global directories such as /usr are not persistent. Concretely I experience that the installation of some self-compiled software (webkit-qt) to global directories is broken after some time until I reinstall it. The relevant webkit installation is installed by the package management at the same time to fullfill dependencies. So each time I install I certainly overwrite some of these files. Please don't tell me that this is not nice to do. I am aware of it. I am just wondering if there is some mechanism in ubuntu which restores the old version of the files (other than the package management if I reinstall some package of course)!

share|improve this question
Why have you decided to install software you build yourself with a prefix of /usr instead of /usr/local? (I think your reasoning might shed light on what solution to this problem would be most appropriate for your situation.) – Eliah Kagan May 14 '12 at 17:06
The software consists of libraries which should be used by packaged software (such as rekonq). Therefore paths must be adjusted to make the packaged software use the correct version of the libraries. This didn't work properly. "So each time I install I certainly overwrite some of these files. Please don't tell me that this is not nice to do. I am aware of it." – highsciguy May 14 '12 at 17:13
Setting the LD_LIBRARY_PATH environment variable seems almost certainly a better ugly hack than the ugly and somewhat dangerous hack of dpkg-diverting and installing in /usr, but both are almost certainly better than the ugly and extremely dangerous hack of replacing files associated with installed packages without telling the package manager. But indeed, depending on how unusual your situation is, any of these (including what you've been doing so far) may be your best choice. My intention was not to say that you're doing it wrong. – Eliah Kagan May 14 '12 at 17:21
Sorry, I didn't want it to sound offending! But setting the LD_LIBRARY_PATH environment variable was exactly what I did. For reasons I don't understand it didn't work for me. But this is infact not my main concern here. I just wonder whether there is something which restores/changes files in directories such as /usr other than the package management. – highsciguy May 14 '12 at 17:26
No problem! Anyways, I've added information to my answer to discuss what can put/overwrite changes in /usr. But the executive summary is: no, the package manager is the only part of Ubuntu that's supposed to modify the contents of /usr. – Eliah Kagan May 17 '12 at 13:33
up vote 1 down vote accepted

If you want to divert files associated with packages that are installed (or that you intend to install), so that you can replace them with your own files but restore them later, you should use the dpkg-divert command.

Since I don't have all the details of your situation, it would be hard for me to recommend specific syntax, beyond the information provided in that manual page.

Other than the package manager and the tools that are part of it (including dpkg-divert), there is no part of Ubuntu that modifies the files in /usr, though if you download and run installer executables, or you build software from source and specify an installation prefix of /usr, then files will be added or overwritten. Most software you build from source and install with sudo make install will, by default, have PREFIX=/usr/local, but some software defaults to PREFIX=/usr so it's worth checking by running ./configure --help or reading the Makefile, before you build and install the software.

The other exception is parts of /usr like /usr/local that are intended to be changed by facilities other than the package manager. But you don't seem to be asking about that. The contents of directories like /usr/bin and /usr/lib should only be modified by the package manager, unless you modify them manually or tell a third-party installer or build process to put files there.

share|improve this answer
I guess then I would need to dig into all the webkit Makefiles, because the installation is by "make install" – highsciguy May 14 '12 at 17:17
The dpkg-divert command affects the official versions of files from installed .deb packages. You can use it before you install self-built software manually with make install. You shouldn't have to edit makefiles for this. If for some reason you do want to change the installation prefix or any other configuration option in the software you're manually installing, most software has a configuration step, where you run ./configure. When there is such a step, the configuration script usually takes command-line arguments to specialize the configuration--try ./configure --help to see. – Eliah Kagan May 14 '12 at 17:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.