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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityApt doesn't support it directly, but there are ways to do it:
.deb
Approachapt-get download package_name # replace `package_name` with the name of the package.
dpkg -x package.deb dir
If the deb
isn't in the Ubuntu repositories, apt-get package_name
won't work, but you may be able to download it from a web site.
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.
schroot
ApproachAnother approach 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.
apt-get source
ApproachFinally, 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.
It used to be possible to install package.deb
with dpkg
into one's 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.
--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.
Jun 13, 2017 at 17:54
--force-not-root --root=/your/custom/path
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:
mkdir /tmp/jedit && cd /tmp/jedit
-- Makes a new diretory in tmp
and changes into it.wget http://mirrors.kernel.org/ubuntu/pool/universe/j/jedit/jedit_4.3.1.dfsg-0ubuntu1_all.deb
-- Download packagear x jedit_4.3.1.dfsg-0ubuntu1_all.deb
or, easy to type, ar x *.deb
-- this extracts the file contentstar xvzf data.tar.gz
-- the file data.tar.gz
has all the stuff which you need for executing the softwareusr/bin/jedit
opens the editorYou can move the files to some point in your home directory and execute them from there.
I wrote a program called JuNest which basically allows to have a really tiny Linux distribution (containing just the package manager) inside your $HOME/.junest directory.
It allows you 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 under all the major Linux distributions, the only limitation is that JuNest can run on Linux kernel with minimum recommended version 2.6.32.
For instance, after installing JuNest, to install jedit:
$>junest -f
(junest)$> pacman -S jedit
(junest)> jedit
I find the accepted answer lacks a concrete example. This is a full working example:
# - opam (snap, no sudo)
# ref: https://askubuntu.com/questions/339/how-can-i-install-a-package-without-root-access
apt-get download opam
#apt-get download opam_1.2.2-4_amd64
#ls | less
mkdir -p ~/.local
dpkg -x opam_1.2.2-4_amd64.deb ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc.user
tr ':' '\n' <<< "$PATH"
opam --version
in particular you need to be careful because apt-get download might now give you the .deb fine with the exact name you expect.
Note this one usually also works:
# - install the bin then put it in path and restart your bash
mkdir ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git .
export PATH="$HOME/.rbenv/bin:$PATH"
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# exec $SHELL
#bash
rbenv -v
dpk -x
andmv
worked for me. Or, if evendpk
is not available,ar
and piping/combining withtar
worked for me on very restricted systems, see here