Several common issues with end user Linux computers come from programs needlessly installed with
Besides the cybersecurity benefits from avoiding
sudo use, it can actually goof up install of programs, putting parts of themselves under
/root or making them readable only by
From those results prima facie one could wonder about the wisdom of using
sudo with the installer script!
In general we write procedures without mentioning
sudo, to avoid end-users carelessly invoking
For almost all installs,
sudo is used with
apt install or
yum install and other commands installing from repositories.
Yes, it is possible to install into a
apt source <myprogram> (if source repositories are enabled) and then build the program.
But most users don’t bother with that.
Configure builds to install locally
Wherever practicable, we tell generators like CMake and Autoconf to install under
~/.local/ as in these examples.
Many Linux distros including Ubuntu are preconfigured to use a hierarchy like
~/.local/lib and so on.
CMakeLists.txt and using CMake ≥ 3.7:
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) if(UNIX) set(CMAKE_INSTALL_PREFIX "~/.local/bin" CACHE PATH "..." FORCE) endif() endif()
Even when using system Python
/usr/bin/python it is often preferred to use the
--user option like:
pip install --user matplotlib
which installs Python modules under
There are some edge cases such as where using GTK3 that using system Python libraries can be useful, such as
python-gi with Beamer.
Big messes are often made when installing with
sudo pip – don’t do that in general.
Also, when installing Python environments (e.g.
which is typically recommended instead of using system Python, don’t use
Most packages that use Autoconf will respect the
prefix= option to specify the top-level install location, like: