If you're familiar with the Linux ecosystem, you're probably familiar with apt/apt-get commands to install packages on Linux. It's seriously all good and great but imagine you be given an account on a Linux box and obviously wanted to install some packages. You just go ahead and $sudo apt-get install your-favorite-package, but only then you realize you don't have superuser right and after asking the system's administrator for those rights he said "No kid I can't do that" you're just a kido.

One way to tackle this is by either hacking the system or using a combination of apt-get and dpkg to download the package and then install it elsewhere because you're really been asked superuser because by default apt-get installs into root directories which all of course require you have those privileges.

For instance, if you wanted to install neofetch, here is how you might want to do this:

david@hplinux:~$ mkdir .root && cd .root #Create a pseudo root directory in your home
david@hplinux:~/.root$ apt-get download neofetch #Download the neofetch package into the current directory
david@hplinux:~/.root$ ls | grep neofetch #Show the full name of the downloaded package
david@hplinux:~/.root$ dpkg --extract $(ls | grep neofetch) . #Extract the package into the current directory
david@hplinux:~/.root$ find . -name "neofetch*" -type f -executable #Find the location where the binary has been installed
david@hplinux:~/.root$ echo 'PATH="$PATH:~/.root/usr/bin"' >> ~/.bashrc
david@hplinux:~/.root$ source ~/.bashrc #Source your bachrs to update the path inside the current terminal
david@hplinux:~/.root$ neofetch #Actually run the command
david@hplinux:~/.root$ which neofetch #Check that the command being run is actually from your pseudo root directory

That last line will just append the location of your pseudo root directory with all it's usr, bin, etc... folder in it to your path, therefore after installing a new package you can just go ahead and run the commands.

That's it! Now you can still do apt-get even if you don't have the super-user privileges. Hope this little tutorial was useful to you !

David :)

Logo

更多推荐