This question possibly has relevance in both Unix & Linux and Stack Overflow; I'm posting at Unix & Linux first, because I think I'd like to understand the issue from the perspective of Unix/Linux convention, before any specific technical implementation.
I'm writing a standalone hello-world application that has need to read a configuration file, config.yml
.
I've been advised that convention is to install the file at /etc/hello-world/config.yml
.
Now, I noticed that /etc/
has write-privilege by root-only:
$ ls -ld /etc
drwxr-xr-x 127 root root 12288 Feb 14 21:16 /etc
I did not set up this Linux PC, but a competent Linux admin did, so I assume this is standard/convention to have /etc/
writable only by user root
and readable by everyone else.
So my question is: how can the install mechanism of my hello-world application (cmake && make install
) install anything in /etc/
if the processes are being run by a non-root user?
In terms of implementation, my "install mechanism" is an install
statement in my CMakeLists.txt
, e.g.:
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
DESTINATION /etc/hello-world/config.yml)
...but again, since I will be running make install
as non-root, this will fail.
Again, I'm asking the question from the perspective of learning Unix/Linux convention -- I imagine this is a common scenario: a lone developer wants to install his config files to "standard" locations, which I was advised is /etc/your-app/your-config
. So how does he go about doing so if /etc/
is writable only by root?
Is it understood that make install
should only be done by root, or a sudo-privileged user, e.g. sudo make install
?
Or is it not correct that config-files should be installed to (a subdirectory of) /etc/
?
Or should /etc/
's permissions allow writing by "others"?