Somewhere in the back of my brain is the memory of reading a cautionary internet voice warning against compiling (i.e. running make) as the root user. Perhaps it's something like this story cprogramming.com.At the same time, it's generally advised that the root user owns /usr/local and its subdirectories.This makes it cumbersome to install software from source:# as rootmkdir programchown user.user program# as userwget/curl/mv program.tar.gz program/.cd program/./configure --prefix=/usr/localmake# as rootmake installIs this the simplest, most proper way to install software from source system-wide? Is it true that make is dangerous as root but make install isn't?
How do I install programs in /usr/local if they shouldn't be compiled by root?
security;software installation;compiling;root
It's all about risk mitigation; if make does something destructive, you can only lose whatever data was modifiable (or deletable) by the user running it. So you run make as a plain user to limit the scope to that user's files, and you run make install as root because you have to if you want to install to /usr/local typically.Note that in the example you give, there's no need to create program as root; download your tarball to your home directory or some other directory you can write to, extract it, configure and build as a plain user:$ wget ...$ tar xf program...tar.gz$ cd program...$ ./configure --prefix=/usr/local$ makeGenerally /usr/local is the default prefix so it can be omitted.If you want to maximise safety, use a dedicated user to build software (so you don't lose your own files if something goes wrong), and of course read the build system at least. make -n can help: it will show you what would be done without actually doing anything. You could also create a special user or group with write access to /usr/local and use that when running make install.