I am using the latest Linux Mint 21.2.

Can I install programs from any directory? For example, if I want to install vim, can I write sudo apt install vim in any directory and linux installs it correctly? For example, I make a random directory: /home/***/dir1/dir2/ and I go there and type sudo apt install vim, does it install vim to /home/***/dir1/dir2/ or some other directory?

How about uninstalling programs? Can I do it anywhere in the system?

What about updating programs with sudo?

  • 2
    @Schmaehgrunza please don't post answers as comments. That circumvents the normal quality control mechanism of the site (voting), it means that your answer will not count so the question will never be marked as answered, and comments are designed to be ephemeral and are regularly cleaned out. Plus, they're harder to find, read and format.
    – terdon
    Dec 14, 2023 at 19:57

3 Answers 3


Yes, absolutely. The location you run a command from has no effect on anything except in the specific case where you use a tool that requires files in its current directory. That isn't the case for any system-wide tool, certainly not for apt. It might happen if you install something manually (i.e. not by using apt but by downloading and compiling from source), but even that is quite rare. Even commands requiring an input file can be run from anywhere as long as you give the correct path to the input.

So no, as a general rule and certainly in the case of apt, where you are is completely irrelevant and you can run any command from any location.


If you use a package manager, then yes, the directory you're installing your program from doesn't matter. That package that is going to be installed knows where every file belongs, and unless you specifically state some other destination, a package manager like apt will use those places.

However, not every software comes with a ready-made apt-installable package, there are other methods of distributing software as well:

  • some come as what's called a tarball, which is just like a .zip archive. You just unpack the archive to install this, and you don't have to be root in most cases. So if you are in /home/Programmer/dir1/dir2 and extract the tarball, you need to call /home/Programmer/dir1/dir2/program later. This is, for example, the case with ModernCSV or Jetbrains IDEA

  • Some software comes as an AppImage, which is the same idea as a tarball, but doesn't even need unpacking. This applies, for example, to Joplin or Guitar. You just download the file to anywhere, then run it from where you've downloaded the file to.

  • If you compile the source code yourself, there will often be a configure step where you state where to install the software, and a make install at the end which copys everything where you said you wanted to have it.

In the latter cases, you'll want to make sure that your $HOME/bin is in $PATH, and you'll make a symlink ln -s $HOME/dir1/dir2/program $HOME/bin/program so you don't need to use a path to call the program.

The reason for people distributing software in this way is mostly because it's easier for them; different distributions of Linux come with different package managers (apt, dnf, rpm/yum, yast/zypper, ...) and it can be quite challenging to provide packages for all of them.

Disclaimer: this is not intended to endorse the linked software in any way, it's just that I wanted to give some examples of software that's installed in those ways (and that I knew about because I use them)


The directory you are in does not affect the destination your package manager installs the packages you request.

You must log in to answer this question.

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