Site Overlay

How to Install Apt Software Packages on Pair Linux Servers Without Root

We Are Not Pair!!! Unofficial Guide!!!

Overview

Pair is a “managed” hosting provider, meaning they don’t give customers root or sudo access. That can make installing and configuring various pieces of software difficult.

It has always been possible to compile software from source. “Its a Unix system!” However, that is a level of complexity many users are not comfortable with.

Nonetheless, people are familiar with the relative simplicity of installing software packages via apt. If only there were a way to do that on Pair servers.

Well there sort of is…

It takes a few additional steps but it is still possible to download packages from the apt repositories and install them locally on Pair servers without root.

Now there are some caveats. Programs that require root access to run, such as iftop, will still not work even if you have installed them locally. You’re Not escalating your privileges with this. You’re just installing binaries in a different place as a non-superuser.

Likewise, complex programs are liable to break. This works well for self contained binaries, ie. shell utilities. However, some programs expect to live at a system level or to call library files from a fixed path. Your mileage may vary.

How To

In our case we’re going to be installing the package called neofetch. Pair servers don’t come with this program installed by default. But they ought to because its pretty cool.

First create a directory named tmp for working in.

mkdir ~/tmp

Then cd down into that directory.

cd ~/tmp

Next download the required .deb file for the software you want to install.

apt download neofetch

Then use dpkg to extract the package to the working dirctory.

dpkg -x neofetch_7.0.0-1_all.deb ~/tmp

Then move the executable neofetch file into your home directory.

mv usr/bin/neofetch ~

Then cd to your home directory and clean up the tmp dir.

cd ~
rm -rf ~/tmp

Finally, run the neofetch command.

~/neofetch

Output

            .-/+oossssoo+/-.               USERNAME@vps###.pairvps.com 
        `:+ssssssssssssssssss+:`           -------------------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.1 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: Bochs 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.4.0-91-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 37 days, 9 hours, 32 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 1313 (dpkg) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.0.17 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1024x768 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   Terminal: /dev/pts/0 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   CPU: QEMU Virtual version 1.0 (2) @ 2.199GHz 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   GPU: 00:02.0 Cirrus Logic GD 5446 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Memory: 679MiB / 1987MiB 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
  +sssssssssdmydMMMMMMMMddddyssssssss+                             
   /ssssssssssshdmNNNNmyNMMMMhssssss/                              
    .ossssssssssssssssssdMMMNysssso.
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`
            .-/+oossssoo+/-.

That looks much better in a 256 bit color xterm terminal window.

We can then create a bin directory and move our executable file into there.

mkdir ~/bin
mv ~/neofetch ~/bin

From there we can add our new bin directory to our path. We can do so quickly by running the following command and then sourcing our new shell file.

  • If echo $SHELL is bash,
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
  • If echo $SHELL is csh,
echo 'set path=($HOME/bin $path)' >> ~/.cshrc
source ~/.cshrc

Finally, we can now run neofetch without needing to provide a path to it.

neofetch

Installing Another Program

Next lets get another utility that isn’t installed on the Pair servers by default but ought to be. Its a fun little shell program called cowsay.

mkdir ~/tmp && cd ~/tmp
apt download cowsay
dpkg -x cowsay_3.03+dfsg2-7_all.deb ~/tmp

From there we can run the cowsay program by specifying a cowfile to use.

~/tmp/usr/games/cowsay -f ~/tmp/usr/share/cowsay/cows/dragon.cow "*happy dragon noises*"
 _________________
< *happy dragon noises* >
 -----------------
      \                    / \  //\
       \    |\___/|      /   \//  \\
            /0  0  \__  /    //  | \ \    
           /     /  \/_/    //   |  \  \  
           @_^_@'/   \/_   //    |   \   \ 
           //_^_/     \/_ //     |    \    \
        ( //) |        \///      |     \     \
      ( / /) _|_ /   )  //       |      \     _\
    ( // /) '/,_ _ _/  ( ; -.    |    _ _\.-~        .-~~~^-.
  (( / / )) ,-{        _      `-.|.-~-.           .~         `.
 (( // / ))  '/\      /                 ~-. _ .-~      .-~^-.  \
 (( /// ))      `.   {            }                   /      \  \
  (( / ))     .----~-.\        \-'                 .~         \  `. \^-.
             ///.----..>        \             _ -~             `.  ^-`  ^-_
               ///-._ _ _ _ _ _ _}^ - - - - ~                     ~-- ,.-~
                                                                  /.-~

To fully install this program and make it a little less cumbersome we’ll do a few things.

First we’ll move the cowsay executable into our bin directory.

mv ~/tmp/usr/games/cowsay ~/bin

Then we’ve got to find a place for the cowfiles. We could just put them in a directory called “cows” or something, but that’s lazy and messy. Instead, we’ll put them in the following place.

mv ~/tmp/usr/share/cowsay ~/.local/share

You may have to create ~/.local and ~/.local/share beforehand if they do not already exist.

We’re now done with the ~/tmp directory so it can be deleted.

rm -rf ~/tmp

Finally, we’ll create a cowsay alias in our shell’s rc file so cowsay is loaded with a default cow when called without the -f flag.

  • If echo $SHELL is bash,
echo 'alias cowsay="~/bin/cowsay -f ~/.local/share/cowsay/cows/default.cow"' >> ~/.bashrc
source ~/.bashrc
  • If echo $SHELL is csh,
echo 'alias cowsay     ~/bin/cowsay -f ~/.local/share/cowsay/cows/default.cow' >> ~/.cshrc
source ~/.cshrc

Then finally we can run cowsay to our hearts content.

cowsay blah blah blah
 ________________
< blah blah blah >
 ----------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Conclusion

It is possible to install some software from apt without needing root. This is certainly not the same as installing software at a system level. Nonetheless, hopefully this provides a work around for someone who needs it.