Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the apt-get install directory [closed]

The default install directory of apt-get is /opt. Can I change it to another directory?

like image 780
tommywang Avatar asked Dec 19 '11 21:12

tommywang


People also ask

How do I change the installation directory in Linux?

The installation path is a standard location and cannot be changed. If you have another drive that has space, you can move any amount of your files to that drive by mounting your big directories at partitions on that drive (this is easiest to do when you are first installing Ubuntu).

Where is apt-get install directory?

Normally it is installed in /usr/bin or /bin if it contains some shared library it is installed it in /usr/lib or /lib. Also sometimes in /usr/local/lib.

Where does sudo apt install put files?

You can find the scripts in /var/lib/dpkg/info/ once the package is installed.


2 Answers

Best way I can think of is to use a symbolic link

note that not all programmes are installed to the same directory and /opt may not be the best thing to move. (see end for example of moving only one folder/program)

This is what I did with EasyPeasy (Ubuntu 10.04)

Follow this code carefully some of the commands can delete important files if used incorrectly.

First you need to make sure /opt (or your distros default apt-get install directory) is empty. If you have data in the opt folder, which you most likely do, you can move it to somewhere else first for safe keeping:

sudo mkdir /New_Location/newtmp                                      # Generates Temporary Folder for Programs 
sudo cp -a /opt/* /New_Location/newtmp                               # Moves Programs to Temp folder

Once backed up you can remove the original directory:

sudo rm -rf /opt/                                                    # Removes opt directory

You can then create your new Program Files folder in a drive with lots of space and create a symbolic link:

sudo mkdir /New_Location/Program-Files                               # Generates New Program Directory
sudo ln -s /New_Location/Program-Files /opt                          # Creates Symbolic Link

Finally move all your old program files to your new folder and clean up the temporary data:

sudo cp -a /New_Location/newtmp/* /New_Location/Program-Files        # Moves Programs to Program Files Folder 
sudo rm -rf /New_Location/newtmp/                                    # Removes Temp folder

If you only wanted to move a single program which is taking up a hunk of your space you could use the same process.

eg: to move Java (JVM approx 300MB) do the following. check directory of java using disk usage analyser. mine is /usr/lib/jvm

sudo mkdir /New_Location/Program-Files/Java                          # Generates New Program Directory
sudo cp -a /usr/lib/jvm/* /New_Location/Program-Files/Java            # Moves Program to new folder
sudo rm -rf /usr/lib/jvm                                             # Removes opt directory
sudo ln -s /New_Location/Program-Files/Java /usr/lib/jvm             # Creates Symbolic Link

Its best at this point to do a restart which should clear the cache.

like image 200
Limited Intelligence Avatar answered Oct 15 '22 15:10

Limited Intelligence


You can't: the installation path is hard-coded in packages (see for example: http://packages.ubuntu.com/oneiric/i386/mono-runtime/filelist). This path is usually /usr instead of /opt, but it depends of the packages. If you want to override the default directory, you must extract manually the content of the packages. But, it can not work: config files, even binary files sometimes, will continue to use the old path. So you must update them in order for the packages to work correctly.

like image 40
CedX Avatar answered Oct 15 '22 14:10

CedX