Create a file in /etc/ as a non-root user

Tim Chase python.list at tim.thechases.com
Fri May 31 20:49:19 EDT 2013


On 2013-06-01 01:20, Nobody wrote:
> On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote:
> > Any Idea how to create a file in /etc as non-root user?
> 
> This should not be possible. The language used is irrelevant.

It's theoretically possible to pre-create the file (or a
subdirectory) in /etc as root, then "chown" it to have a group for
which certain users can be members.  Something like

  $ su -   # or "sudo sh"
  # addgroup bibhusers
  # mkdir /etc/bibhu
  # chown :bibhusers /etc/bibhu
  # chmod g+rwx /etc/bibhu
  # for user in bibhu tim guido; do adduser $user bibhusers ; done
  # exit
  $ logout

Upon next login, the users listed in the "for user in ..." command
should have write access to the directory created in /etc

Not that this would generally be considered a good idea, but if you
wanted to have a global configuration and wanted select users (as
members of a defined group) to have the ability to tweak this global
configuration, this is how it would be done.  Otherwise, it's
generally advisable to just have one admin maintain the global
configuration file and then give users a local (in
$HOME/.config/$APPNAME/filename.ext) configuration file to override
those global settings.

-tkc






More information about the Python-list mailing list