Proper way to build from sources
Solution 1
Your 3rd version is correct, ./configure && make && sudo make install
. Make and configure can be done as a normal user since you aren't trying to write files in a system directory, make install
will often try to copy the binaries to /usr/bin or /bin which requires root access to write.
Solution 2
You need the last version:
./configure && make && sudo make install
Configure and make can happen in your local folder but you'll need root permissions to install. That command accomplishes it.
Make sure the application you're installing isn't in the package manager already. It's typically much easier to use the pre-compiled software for your system than trying to find all the dependencies to compile something.
Solution 3
The && are parsed by your original shell. Putting one sudo at the front only affects the configure. The last option makes the most sense, because it will configure and compile as a regular user and then install the results for everyone to use.
One caveat is that some configure scripts will detect that they are running as non-root users and create makefiles that install into $HOME or similar. In that case, you'd want to 'sudo ./configure' as well. If you run either the configure or make as root you will have the annoyance of some root-owned files in your regular-user directory.
Solution 4
Option number 3:
./configure
make
sudo make install
Solution 5
Instead of sudo make install you should use sudo checkinstall
This way, the installed program is recognized by the package management and you can remove it again, should you no longer need it.
Related videos on Youtube
8k_of_power
Updated on September 17, 2022Comments
-
8k_of_power over 1 year
I am logged in as a regular user. Should I use:
./configure && make && make install
or
sudo ./configure && sudo make && sudo make install
or
./configure && make && sudo make install
when installing packages.
And could someone explain the differences.
I want all users to be able to use it.
-
reinierpost over 13 years... and which should not be written to because their content is managed by package management.
-
reinierpost over 13 yearsYou might even go so far as to create a user
local
, then issue achown -R local /usr/local
and then install software usingsudo local make install
so you will be warned when a package writes somewhere else than underneath/usr/local
(which can mess up your package management). -
William Pursell about 13 yearsIf the package is built in accordance with the gnu coding standards, a raw 'configure && make && sudo make install' will only install in /usr/local, and not in /usr/bin or /bin.