Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  15] [ 0]  / answers: 1 / hits: 20716  / 2 Years ago, mon, june 13, 2022, 10:42:51

This is probably a stupid question, but I recently realized that I have no idea why there's no single-user functionality with apt-get.



Answers I'm not looking for:




  • "It's because apt writes to system-level directories". This is the surface-level why, but I'm looking for a level deeper. Is there something fundamentally blocking a single-user environment (a la pip + virtualenv)?

  • "You can just build from source". This is a workaround, but does not address my question. I don't want to fix a short-term issue, and I have root access on all of my machines anyway.


More From » apt

 Answers
0

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.


[#26311] Wednesday, June 15, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kneducator

Total Points: 226
Total Questions: 111
Total Answers: 108

Location: Mexico
Member since Sun, Jul 25, 2021
3 Years ago
kneducator questions
Tue, Dec 6, 22, 09:22, 1 Year ago
Sun, Apr 30, 23, 23:26, 1 Year ago
Tue, Jun 8, 21, 01:25, 3 Years ago
Sun, Mar 12, 23, 10:51, 1 Year ago
;