How to install program locally without sudo privileges?

Assume I have ssh access to some Ubuntu server as user and I need some not system tools to be installed for convenience (mc, rtorrent, mcedit). I do not want to bother admins for these small programs.

Is there a way to install them (make them run) without using something like sudo apt-get install?

Asked By: yura


You need to compile these from source. It should just be a matter of

apt-get source PACKAGE
./configure --prefix=$HOME/myapps
make install

The binary would then be located in ~/myapps/bin. So, add export PATH="$HOME/myapps/bin:$PATH" to your .bashrc file and reload the .bashrc file with source ~/.bashrc. Of course, this assumes that gcc is installed on the system.

Answered By: eof
  1. Compile and install into ~/bin (and edit your .bashrc to set the PATH to include it). libraries can similarly be compiled and installed into ~/lib (set LD_LIBRARY_PATH to point to it), and development headers can be installed into e.g. ~/includes.

  2. Depending on the specific details of the programs you want to install and the libraries they depend upon, you can download the .deb files and use ‘dpkg-deb -x‘ to extract them underneath your home directory. You will then have a lot of “fun” setting the PATH, LD_LIBRARY_PATH, and other variables. The more complex the program or app you’re installing the more fun you’ll be up for 🙂

    You will, of course, not be able to install setuid binaries this way – they’ll install but (since you don’t have permission to chown them to root or set the setuid bit on them) they’ll just be normal binaries owned by you.

    Similarly, daemons and system services that expect to be running as a certain UID or have the ability to change uid, or expect files to be in /etc rather ~/etc and so on aren’t likely to work well, if at all.

  3. Most sysadmins would consider mc and mcedit to be “mostly harmless”, innocuous programs.

    Very few, however, would consider installing a torrent client to be harmless, especially if they have to pay for bandwidth or end up being legally liable. Most sysadmins would probably not be entirely happy for end-users to be installing such software without permission. They may say “sure, go ahead, knock yourself out” or they may not…but you should ask about anything that may cause problems for the owners/administrators of the machine.

Answered By: cas

You can use JuNest, which creates a small Linux container in user’s directory, where you
can install any packages.

Answered By: niutech

I faced the same issue, here is how I quickly fixed it, assuming you have a linux server of the same OS and architecture.

  1. Install the software on the system you control

  2. Find the executable example which python and copy it to ~/

  3. Copy the libraries with:

    ldd "$(which python)"  | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' ~/

Transfer the executable and the libraries to the other system where you only have local privileges, then run the following:

mkdir ~/lib
export PATH="$PATH:~/lib"
export LD_LIBRARY_PATH=~/lib:/lib:/usr/lib

This will create a folder ~/lib to store the libraries, add it to your path, and tell LD to look at the libraries there, so just add your executables and the libraries there, now you can run it as you’d elsewhere

This may be very hacky, but it’s very portable, quick, and I haven’t yet found something I can’t run that way, of course, the software cannot try to do things that need root access, like binding to a lower port than 1024, etc.

Answered By: Freedo

There’s actually a tool for that that i just made today
All you need is access to bash no root are anything special
You can use whet to download it as a zip file or use git clone

Answered By: echo

Concrete examples that worked for me:

#!/usr/bin/env bash

# - install the bin then put it in path and restart your bash
mkdir ~/.rbenv
cd ~/.rbenv
git clone .

export PATH="$HOME/.rbenv/bin:$PATH"
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
#    exec $SHELL

rbenv -v

# - opam (snap, no sudo)
# ref:
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
Answered By: Charlie Parker

This is much better, found on askubuntu:

Software Updates uses aptdaemon to do all the work. You can do that > from the command line using aptdcon:

Check for updates:

aptdcon --refresh

Install updates:

aptdcon --safe-upgrade
Answered By: Gringo Suave

Here’s how to install into local user bin directory, without using sudo:

install ./your-app ~/.local/bin/

Alternatively, just copying the app to that directory should also work.

Answered By: Noam Manos