Why does apt-get require sudo?
Not always. You can perfectly use apt-get
without sudo
. There are instances where you don't need sudo
at all, like using apt-get download
which downloads a package to your current directory, apt-get source
which downloads the debian sources files to your current directory, changelog
which downloads and prints the changelog of a given package, and any command which has the --simulate
/--dry-run
/--no-act
(in the case of install
you need also --no-download
).
This is because these actions/commands doesn't require to write system directories.
Now, why apt-get
needs sudo
? Actually it doesn't. You can ditch apt-get, download a package with wget
and use dpkg --extract
and extract the package in whatever directory you like. There's also --instdir
which should work for binary only package.
Now, why this isn't the default? Because it's a pain. To do what you want, we would need to repackage each package twice, one for the right way, and another to do what you want. At build, binaries normally need to know where are the files and libraries they need (in some cases, this is hardcoded at compilation).
Now, what you can do instead? Just chroot some environment a la virtualenv, where you can install packages without root.
Summary, this is not the way that apt-get was meant to be used, and I don't know another package manager similar to apt-get which allows you to do that. At the end of the day, apt-get
is just a front-end to dpkg which could do some of this.
Best Answer
Check the PATH variable (echo $PATH) to see if there's something wrong there (please post the output here).
Also, try to copy a clean .bashrc file from /etc/skel (backup your current ~/.bashrc file before)
Hope this helps ;D