Is there a way to have the update-alternatives command operate on a root file system mounted on a path other than '/'? For example, the update-rc.d and ldconfig commands have an -r <path> option to do this. The update-alternatives man page does not indicate such support.

  • Can you chroot in into the root file system, and run the command in that chroot? Sep 10, 2015 at 19:55
  • Thanks. I had resolved this issue with some shell scripting to do the equivalent of the update-alternatives command. The chroot option looks like it will also work and would be simpler.
    – Jay
    Sep 11, 2015 at 16:54

1 Answer 1


You can use the --admindir option to choose a state directory such as /my/root/var/lib/dpkg/alternatives, and the --altdir option to choose a link directory such as /my/root/etc/alternatives. However update-alternatives will see absolute symbolic links in /my/root/etc/alternatives, pointing to /usr/bin and the like, so it might see broken links for programs that aren't installed in the alternate root.

There's no option to tell it to work entirely inside a root. So use the generic method: chroot.

chroot /my/root update-alternatives …

If you don't want to run as root, you can use fakechroot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .