Installing software from source on Linux: how it works and when you shouldn't
Many open-source projects include instructions to "build from source." It's a useful skill, but usually not the first option you should reach for.
What building from source means: You download the project's code and compile it on your machine, instead of installing a ready-made package.
A typical flow (it varies by project):
- Install build tools and the project's listed dependencies.
- Get the code with
git cloneor by downloading a release archive. - Configure the build, for example with
./configure,cmakeormeson. - Compile, often with
makeorninja. - Install, sometimes with
sudo make install.
Always read the project's README or INSTALL file, since every project differs.
When it makes sense:
- You need a newer version than your distro offers
- You want to change the code or contribute
- The software isn't packaged for your system
Why to try other options first:
- Your package manager handles updates, security patches and clean removal
- Self-compiled software won't update automatically
make installcan scatter files around the system that are hard to remove- Flatpak, Snap, AppImage or the project's official repository may give you a newer version easily
Safer habits: install into your home directory or /usr/local, keep a note of what you built, and only build code from sources you trust.
What's the first thing you ever compiled from source? Do you prefer Flatpak-style packages or distro packages?
Comments · 4
Always prefer your distro's package manager first. Source builds skip updates, and removing them cleanly later can be a pain.
Read the build script before running it. If you wouldn't run an unknown binary, don't run an unknown make install as root either.
What is the usual "configure, make, make install" trio doing, step by step?
Configure checks your system and sets up the build, make compiles the code, and make install copies the results into place. Use a prefix to keep it out of system folders.