nitin kumar nitin kumar - 4 months ago 12
Linux Question

How to install a package in user defined directory using apt-get?

I'm using ubuntu, whenever I install any package it gets installed in standard directories

/usr/lib
/usr/local/lib
etc.

I want to install a package in a non standard directory. Is there any way to do this?

Answer

It is generally discouraged as you'll run into many complications like dependencies and where they're all located and linked at, but if you still want it to give it a shot, you could either do 2 of the following:

1. Compile from source

This would allow you to modify where you want each package to go and their contents, however this will require more work than the next option.

2. Chroot

Chroot is basically a 'jail' for anything you run inside it. What it does is create a special directory and sets that as root for anything you run inside it. It's been used to test applications or even test upgrade/downgrade systems. However, note that it is not a security feature as an executable can still possibly break out of the 'jail' and affect the main system. For your purposes this might be what you want to look at. Here's how to use Chroot and also why it isn't a security feature.

These 2 are discussed in detail in this AskUbuntu link. In fact your question would be more suited there if those answers from that question do not give you the answer you seek.

Other than that I suppose packages that are Dockerized allow for a different path to deployment tutorial here or a VM, which isn't your question but just an alternative which might be acceptable to you.

Comments