116

I have no root access on this machine.

I would like to know if there is a way I can download Ubuntu packages and install them as non-root?

Probably in my ~/bin or ~/usr/share or something like that? Would that work?

  • Hopefully, they will support it soon. – Domi Apr 3 '14 at 9:50
  • 3
    You could use portable apps for linux: no installing , no root necessary. Find it at appimage.org. Even Linus Torvalds likes it. That's odd, cause Linus never likes anything. – ipse lute May 27 '16 at 22:26
  • I suggest trying fakechroot. – Robert Pollak Mar 16 '17 at 15:34
  • A combination of dpk -x and mv worked for me. Or, if even dpk is not available, ar and piping/combining with tar worked for me on very restricted systems, see here – iolsmit Jul 24 '18 at 12:25
100

Apt doesn't support it directly, but there are ways to do it.

One is to use schroot to create a non-root chroot. This is a somewhat involved process, but one you should be able find community help for as many developers set up chroot environments for compiling code.

The second way I know of is to install from a .deb package. You may be able to download this from a web site or if it's in the Ubuntu repositories you can download with.

apt-get download package

Replace package with the name of the package

Once you have your deb file call dpkg directly from the command line. The following example will install package.deb into your home directory.

dpkg -i package.deb --force-not-root --root=$HOME 

The disadvantage to using dpkg like this is that error messages are likely to be cryptic; dpkg doesn't automatically resolve dependencies or create the directory structure it expects.

Finally, you could use the apt-get source command to fetch the source of the package and configure it to install locally. Usually this looks something like:

apt-get source package
cd package
./configure --prefix=$HOME
make
make install

The disadvantage to this approach is that you need the development environment available for this approach to work at all, and you might find yourself compiling dozens of packages in order to resolve all the dependencies.

EDIT:

As dpkg -i doesn't work (see comments), I suggest this alternative:

dpkg -x package.deb dir

This will extract the .deb package to dir. Then you can export the PATH where the binary is. As long as all dependencies of the binary are installed, it should run as normal.

  • 1
    If you have root access but just don't want to install a particular package globally, you could use sudo apt-get build-dep package to install everything required to build a package (after getting its source with apt-get source). – Vladimir Panteleev Jan 14 '13 at 22:25
  • 19
    This answer was written back in 2010. Have there been any changes to how this is done since then? – becko Sep 16 '14 at 18:30
  • 35
    Even with --force-not-root, I get "dpkg: error: requested operation requires superuser privilege" – Clément Apr 19 '16 at 13:37
  • 9
    Folks, --force-not-root --root=$HOME, or variations thereof will not work. Debian binary packages are not designed to be installed in the home directory, period. Or, to put this another way,. "The following example will install package.deb into your home directory.". No, it won't. – Faheem Mitha Jun 13 '17 at 17:54
  • 1
    Sadly this won't work. I tried --force-not-root --root=/your/custom/path – Viet Jun 22 '17 at 10:12
16

I assume you want to install jedit. First you have to find the package and download it. I just take the deb file from some mirror and open a console/terminal:

  1. mkdir /tmp/jedit && cd /tmp/jedit -- Makes a new diretory in tmp and changes into it.
  2. wget http://mirrors.kernel.org/ubuntu/pool/universe/j/jedit/jedit_4.3.1.dfsg-0ubuntu1_all.deb -- Download package
  3. ar x jedit_4.3.1.dfsg-0ubuntu1_all.deb or, easy to type, ar x *.deb -- this extracts the file contents
  4. tar xvzf data.tar.gz -- the file data.tar.gz has all the stuff which you need for executing the software
  5. usr/bin/jedit opens the editor
  6. done :-)

You can move the files to some point in your home directory and execute them from there.

  • 11
    Note that pre- and post-install scripts don't get run; also you'll need to resolve any dependencies or paths yourself. But on a default install this is sufficient for a lot of desktop applications. – jbowtie Jul 29 '10 at 12:01
  • you can also download the package without searching for it, just do apt-get download (see other answer) – lib Jul 23 '15 at 14:59
  • i believe your link is broke. – Winnemucca Apr 13 '17 at 22:33
9

I wrote a program called JuJu which basically allows to have a really tiny linux distribution (containing just the package manager) inside your $HOME/.juju directory.

It allows to have your custom system inside the home directory accessible via proot and, therefore, you can install any packages without root privileges. It will run properly to all the major linux distributions, the only limitation is that JuJu can run on linux kernel with minimum recommended version 2.6.32.

For instance, after installed JuJu to install jedit:

$>juju -f
(juju)$> pacman -S jedit
(juju)> jedit
  • This will run just fine on Ubuntu right? – Seth Nov 2 '14 at 21:27
  • Yes, if the linux kernel version of ubuntu is greater or equal to 2.6.32 it will work. – user967489 Nov 4 '14 at 0:47
  • 2
    At first I thought you were talking about this. The second capitalized j makes the difference. – kon psych May 6 '15 at 21:42
  • The question was if we could install Ubuntu package. With junest, we will only be able install ArchLinux package and NOT an Ubuntu package. For e.g. if the same package is not available for ArchLinux, then this won't help. That said, thanks for Junest. – Kiran Feb 20 '16 at 10:24

protected by Byte Commander Mar 17 '16 at 9:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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