16

When I moved from Windows to Linux, I have been mercifully blessed with package managers. Most of the time, the official repositories of my distro (currently Debian 12) will have the package I need. But sometimes it will not, which means that if I want to install some apps, I have to do it without going through the package manager ; maybe by cloning a GitHub repo and building from source, or by using wget or curl to get a purpose-made installer from the developers.

Is it safe to do this? I'm not asking about the trustworthiness of these packages. Rather, will it break the package management system if I do this? Will packages installed in such a way be updated when I use my distro's package manager to perform a system-wide update, for example? Will I be able to use the package manager to uninstall them?

Here is a concrete example. Say I want to install Rust. The official Rust website informs Linux users to run the following command.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

In other words, download the rustup.rs file from the website, and then run it to install Rust. This example is doubly puzzling for me, since Debian does have rustup available as a package in the repos. So should I use the Debian package, or should I follow the instructions on the website?

Here is another example. Say I want to install Minecraft, which is not available in the Debian repos. I must thus go to the Minecraft website, which lets me download a minecraft.deb file. If I am correct, I would then use apt to install it. In this case, would the package be tracked by the package manager? Would I be able to uninstall it, or update it with apt?

Thank you from your help in clearing this confusion, which has been bugging me for quite some time.

4
  • 1
    This question is similar to: Is it mostly safe to install any software from default repos? ( "yum install" "apt-get install" , etc). If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 5 at 9:33
  • 1
    A malicius package file (.deb, .rpm etc. file) can compromise (hurt) your system, because the package manager runs the preinstall commands within the package file, as root. Thus download+(sudo dpkg -i) is just as secure as (curl|sudo sh).
    – pts
    Commented Sep 5 at 13:27
  • 2
    You're overlooking an option: build your own package and install it via the distro's package manager. This is more complicated than directly building and installing from source or similar, and you may not consider it worth your while, but if done right it conveys all the advantages of your distro's package management other than the usual convenience. Commented Sep 5 at 15:07

5 Answers 5

17

Generally speaking, yes, it’s safe, assuming the software provider is trustworthy and the software you’re installing hasn’t been tampered with (I didn’t address that because you explicitly said you were “not asking about the trustworthiness of these packages”; see Gilles’ answer for a thorough comparisong of safety against attacks). As long as anything installed not using a package is installed in /usr/local or /opt, and doesn’t add itself to global system configuration files, you shouldn’t break your system.

Your question doesn’t mention installing from source; but usually when doing so, software installs itself in /usr/local by default if it can (that is to say, you are able to run the installation as root).

Another “safe” installation location is somewhere under your home directory. This has the advantage of not requiring administrator privileges, which guarantees that your system can’t be completely broken — you’ll still be able to log in as another user. However since most of the data you care about is in your home directory, this might not make much difference against errant installers or mistakes. In particular, never use your home directory itself as an installation prefix (I have seen users lose all their data this way), use a subdirectory — $HOME/.local is a good candidate.

I’ll address the last part of your question first because it’s simplest. If you download a .deb file and install it (using apt install ./minecraft.deb for example, which is better than dpkg -i minecraft.deb because it will take care of dependencies for you), the package manager will then be aware of the package. This is good because it means that the package’s dependencies won’t be removed accidentally. You will also be able to uninstall the package using apt. However installing a package in this manner doesn’t necessarily guarantee that you will be able to update it with apt; the exception is packages which configure their own repository (e.g. many Google packages). You can always manually upgrade such packages by downloading a new package and using apt install again to install it.

Language ecosystems and associated tools such as rustup are a bit more complex. Just to get rustup out of the way, it is available as a Debian package, but only in Debian 13 and later (see the rustup installation manual); so you can’t use apt install rustup as-is on Debian 12.

Most language ecosystems are aware of distribution packaging constraints and work well alongside the packages in the distribution. You can install the latest release of Go for example alongside the packaged Go in Debian, and everything will work fine. The same is true of Java, and since Debian 12, Python as long as you use virtual environments. The only things to absolutely make sure of is that you never replace the system binaries (those in /usr/bin) with incompatible versions; this is especially rampant with Python, and there are loads of questions here arising from users replacing /usr/bin/python3. As long as you don’t do something like that you should be fine.

4
  • 6
    By convention, when you build something from source and run the associated install command (if it has one) it will typically install to /usr/local/ or to $HOME by default, which should be safe. However, this is only a general guideline that well-behaved packages should follow, and not a guarantee that any particular package you want actually does so. You will need to inspect the installation instructions to determine where and how it installs.
    – Miral
    Commented Sep 4 at 7:12
  • Thank you for helping in clearing up my confusion! My instinct is always to use the distro's package manager whenever possible, and to be wary of other installation methods, but now I know a little better, as well as what to look out for. I also hadn't noticed that rustup wasn't available yet as a Debian package, like you and other users have pointed out.
    – Thomas.M
    Commented Sep 4 at 11:56
  • 2
    Also, you'll be safer if you don't use sudo to do the build/install, since you shouldn't be able to replace the system binaries, etc. Of course you generally won't be able to install to /usr/local/ then, but maybe that's a good thing.
    – jrw32982
    Commented Sep 4 at 20:23
  • Very relevant xkcd xkcd.com/1200 Commented Sep 6 at 22:24
8

Software installed outside of the package manager is generally not tracked by it.

Installing software manually might lead to conflicts with packages installed through the package manager. If the manually installed software relies on specific versions of libraries or tools, this might clash with versions managed by your package manager.

If you install software manually from source or via a script, you’ll need to follow the uninstallation instructions provided by the software, which might not integrate with your package manager.

Whenever possible, use your distro’s package manager. It simplifies updates and dependency management.

.deb package can be installed with dpkg or apt

How to install a deb file, by dpkg -i or by apt?

sudo apt install package.deb

sudo dpkg -i package.deb

dpkg is a low-level package management tool for Debian-based systems that installs, removes, and manages .deb packages directly.

Try to use Debian repositories if possible.

Don't forget, not all packages are in the Debian main contrib repositories.

You have to modify your /etc/apt/sources.list

This is my sources.list:

## MAIN STABLE
deb http://deb.debian.org/debian bookworm main
deb-src http://deb.debian.org/debian bookworm main

deb http://deb.debian.org/debian-security/ bookworm-security main
deb-src http://deb.debian.org/debian-security/ bookworm-security main

deb http://deb.debian.org/debian bookworm-updates main
deb-src http://deb.debian.org/debian bookworm-updates main

## NON-FREE
#deb http://deb.debian.org/debian bookworm main non-free-firmware
#deb-src http://deb.debian.org/debian bookworm main non-free-firmware

#deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
#deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware

#deb http://deb.debian.org/debian bookworm-updates main non-free-firmware
#deb-src http://deb.debian.org/debian bookworm-updates main non-free-firmware

## BACKPORTS
#deb http://deb.debian.org/debian bookworm-backports main contrib non-free
#deb-src http://deb.debian.org/debian bookworm-backports main contrib non-free

## UNSTABLE
#deb http://deb.debian.org/debian/ unstable main
#deb-src http://deb.debian.org/debian/ unstable main

After making the change, run sudo apt-get update or apt update to update the package list.

What is the difference between apt and apt-get?

Just so you know, there's another package manager called Synaptic.

It's a graphical frontend for apt and dpkg that provides a user-friendly interface.

Users can search for packages, view information about them, and install or remove them with a click.

It displays dependencies and suggested packages, giving the user more control over package management.

Synaptic is a graphical interface to the Debian package management system.

7
  • 1
    rustup isn’t available in the Debian 12 repositories. apt install can install manually-downloaded packages too, and resolves dependencies unlike dpkg -i. Commented Sep 3 at 16:57
  • You right only in sid : packages.debian.org/sid/rustup
    – Z0OM
    Commented Sep 3 at 17:00
  • 1
    It’s also in trixie but not in Debian 12. Commented Sep 3 at 17:36
  • 1
    Thank you for the helpful explanation of how to install a .deb file with apt or dpkg! I knew it was possible, but never really knew how to do it. Turns out it's quite simple in fact.
    – Thomas.M
    Commented Sep 4 at 12:03
  • 2
    Beware of installing Ubuntu .deb packages onto a Debian system - sometimes you will get a different software version which could cause future conflicts. Commented Sep 4 at 19:10
6

This is not generally possible to answer, since we don't know what the installation entails, especially so when installing something via a command like this:

 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

The script could be doing anything. It could be adding a repo and installing something from that repo (and there are plenty of curl | sh scripts that do so). It could show up as different scripts in different locations (it probably doesn't here, but it could). That minecraft deb package could be adding a repo. Either of these could very well break package management systems (if they do use it, in the case of curl | sh scripts), if they add a repository which then adds some package that shadows or conflicts with some other package you want to use from the distro's repos.

And not just deb files or random scripts. Installing arbitrary Python packages as root (which the script could be doing) is known to break package management systems, and that's why PEP-668 came along (leading to posts like pip error on Ubuntu: externally-managed-environment × This environment is externally managed and How do I solve "error: externally-managed-environment" every time I use pip 3?). The script could be compiling and installing OpenSSL or some such core library, and break your package management commands simply because the library got installed in a way that overrode the system libraries.

In cases of the curl | sh scripts, I generally prefer to look at the script myself, extract out the parts that are relevant to me and the systems that I am using, and execute those myself.

In this case, would the package be tracked by the package manager? Would I be able to uninstall it, or update it with apt?

In this case, yes, the package would be tracked by apt/dpkg. You would be able to uninstall it. Some deb files (notable Google Chrome) do add repos as part of the package installation which then allow you to use apt to update them, but you might need to manually download new deb files and install them again if no such repos are added.

5
  • Indeed this is exactly what my concern was : the potential of an installation script to do anything, and potentially things it shouldn't. The intricacies of package management are still somewhat beyond me, but thanks to all the answers provided here, I at leat know what to stay alert for.
    – Thomas.M
    Commented Sep 4 at 12:01
  • @Thomas.M I hope that means that you won't blindly do curl | sh at least - that you'll download the script first, inspect what it does and then run it
    – muru
    Commented Sep 4 at 14:05
  • I pinky promise.
    – Thomas.M
    Commented Sep 4 at 16:02
  • If you're running curl | sh as a normal user and you trust the script, then package-management-wise, you should be OK, as long as the script doesn't use sudo internally. Unless the script is evil, in which case your machine has just been pwned.
    – jrw32982
    Commented Sep 4 at 20:58
  • 1
    When you build from source, often the install (and build) phase allows you to specify installation to a non-system directory, such as under your home directory.
    – jrw32982
    Commented Sep 4 at 21:01
6

It’s impossible to be sure when you’re effectively ‘taking the Windows approach’ and downloading and running some random bit of software. Some is well behaved and will put everything under /opt or /usr/local like it needs to to avoid interfering with the system package manager. As an example, the official upstream Go toolchain from https://go.dev does put everything under /usr/local on UNIX-like systems (actually /usr/local/go). But not all software is well behaved like that, and it’s difficult to be certain.

There are a few special exceptions to all of this:

  • Flatpaks are safe. They are designed specifically for this type of software distribution and are largely guaranteed to correctly handle things. In some cases these are even preferred over the distro package manager because they work more reliably (Steam is a prime example of this) or provide better security.
  • Snaps and AppImages are also safe in the same sense that Flatpaks are, though I would generally recommend a Flatpak over either a Snap or AppImage (Flatpak usually has less overhead, better desktop integration, and an easier to work with permissions model).
  • OCI containers such as Docker/Podman are safe. Again, these are designed for this type of usage. These are actually the preferred approach for toolchains like Rust, Elixir, Node.JS, or even Python in many cases, as it’s very likely you will want other things not packaged by your distro as part of working with the language.
  • Applications/tools written in Go are generally safe if installed using the go tooling (go install). The Go toolchain manages these in a sub-directory of your home directory, and they are essentially 100% self-contained, so there’s almost no risk involved unless they write to arbitrary files across the system.
  • Third-party repositories for the system package manager are safe (specifically in the sense that they will not inherently break the package manager), but may not work completely with the system.
  • Isolated packages in the system’s native format are safe in the same sense as third-party repos, but they tend to use Windows-style automatic self-updates (the Minecraft DEB for example just ensures required packages are installed and then installs a minimal bootstrap setup that will then download the actual Minecraft launcher, which will in turn download Minecraft itself, Dropbox is known to do something similar and I think Google Chrome does too), which has some potentially nasty security implications.
4
  • Thank you for this detailed explanation of what kinds of installation methods are "safe" to use! It'll be very useful to me in the future, and I've no doubt I'll be referring to it if I have a doubt later on.
    – Thomas.M
    Commented Sep 4 at 11:58
  • 1
    Flatpacks etc don't get any kind of system integration test. Personally, I avoid all non-apt packaging systems. Commented Sep 4 at 19:14
  • 1
    @JeremyBoden As long as you trust that the distro maintainers packaged the Flatpak tooling and Bubblewrap correctly and that there are no bugs, you can absolutely trust that installing any arbitrary Flatpak will not break your package manager, and that running it won’t trash your system without asking you for permission to do so first. And ‘integration’ testing is not exactly needed barring possible special limits on kernel configuration, because the set of APIs involved for a Flatpak is very very well defined. Commented Sep 4 at 22:47
  • @JeremyBoden It’s very unusual as a result for a given Flatpak to not work on a specific system as long as the distro components were packaged correctly. They almost always break everywhere, or work everywhere, with cases in-between usually being isolated to things like custom built kernels or the user poking around in places they shouldn’t be. Commented Sep 4 at 22:48
3

Comparison of package safety

There's no such thing as absolutely safe or absolutely unsafe. It's all relative. But relatively speaking, distribution packages are generally safer for multiple reasons. That shouldn't prevent you from installing non-distribution packages when you need them. But if a program is available both as a distribution package and from another channel, you should use the distribution package if possible.

By “distribution package”, I refer to packages distributed directly by major distributions such as Debian, Ubuntu, Red Hat, SuSE, Arch, FreeBSD, etc. Distributions with less manpower may have less relative safety. Packages downloaded manually in the distribution format (e.g. a .deb or .rpm) do not have the safety advantages of distribution packages. Packages installed from additional package sources (e.g. Ubuntu PPA) are in between.

Transparence

Distribution packages are signed and replicated, and the installer verifies the signature. So you know what you're getting. If a bug is discovered in a given version, you'll at least be able to know whether you had the buggy version.

In contrast, when you install something with curl https://example.com/run_me.sh | bash, you have no way to know what you installed. A malicious web server can return a clean installer if you download the .sh, but a backdoored installer if you run curl … | bash, by detecting the timing of pauses in the execution of the installer script. This even distinguishes curl -o install.sh … from curl … | bash.

Third-party package sources are in between: they're only signed by their vendor, but some (such as Ubuntu PPA) are hosted by distributions, which at least prevents undetected substitutions.

Scrutiny

Software shipped by distributions get some scrutiny. It's not a lot, and absolutely not something that can prevent bugs or backdoors. But it's enough to make it harder to ship a backdoor that goes undetected for a long time. And it means that the software is trusted by at least one person who is trusted by a distribution.

Getting the software directly from the vendor removes one layer of scrutiny, whether you get it from a package source or a website download.

Security updates availability

Distributions have people who make security updates when a vulnerability is discovered. That includes porting security fixes to the distributed version of the package. Except with rolling distributions, in a given version of the distribution, you only get major bug fixes, so you can be reasonably confident that the fixed version won't have new features that interfere with your workflow.

Some vendors follow the same principles. Others don't.

Security updates automaticity

For any software that comes through your package manager, a single command (e.g. apt update && apt upgrade) applies all the security updates. Some distributions or desktop environments set up automatic tasks to apply security updates, or to prompt you to apply security updates.

For software that comes through other channels, you have to remember to go and look for updates. So you might have vulnerable software for a long time before you notice.

Package automation

Most packaging systems keep track of which package owns which files. They signal an error if a package tries to overwrite a file from another package. They remove all the files of a package when you uninstall it. This applies to anything that uses the packaging system, regardless of who made the package.

You do not get these benefits from manually installed software.

Package quality

Distributions have minimum package quality requirements. For example, they follow directory structure conventions. They won't disrupt your system or your user account in arbitrary ways. They clean after themselves when you uninstall them.

Third-party software, whether it comes as a package or not, may or may not reach this quality.

Integration quality

Distributions don't do much testing of most of the software that they ship. But at least they make sure that all dependencies are satisfied — you won't end up with software B requiring A version 1.3, software C requiring A version 1.4, and no way to install both versions of A. In particular, a given version of a distribution compiles all the programs against a given set of library versions. Distributions solve DLL hell for you.

If you install software that isn't from the distribution, you're on your own. The vendor may or may not have tested with a system that's similar to yours. Two different vendors may have completely different expectations of a typical system.

That's why a lot of vendors now ship “appliances”: instead of just shipping an application, they ship the application and all the libraries it depends on. Sometimes they go as far as putting the application in a container: flatpak, Docker image, virtual machine… That solves the dependency problem, but it also means that the libraries in the container don't get bug fixes (and in particular security fixes) unless the vendor applied the fixes to their own copy of the library. In practice, that never happens, so we get back to the security update availabiltiy problem I mentioned above.

About language ecosystems

If you're a developer, in many programming languages, language-specific distribution channels (pip, npm, rustup, hackage, opam, …) are hard to avoid.

Unfortunately, the state of packaging is pretty bad. The one good thing is that they handle versioned dependencies. These package managers barely keep track of which files belong to who. They may or may not be able to clean everything up when uninstalling.

These ecosystems usually give up on DLL hell and just tell you to install separate copies of everything in each of your build trees, or at least one per (version of a) project. But if your project needs libraries A and B, which both need library C but at different versions… sucks to be you.

So you should avoid language ecosystem packaging if you can, but often, you can't. You need to spend some effort in reviewing and maintaining your supply chain.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .