top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

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

0 votes
44 views

I am a python script which tries to create a file under directory /etc/ but I am getting the error as

IOError: [Errno 13] Permission denied: '/etc/file'

Any Idea how to create a file in /etc as non-root user?

posted May 31, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

3 Answers

0 votes

That is not a Python problem, but a permission one. You should configure the permissions so that you have write access to the folder. However unless you know what you are doing it is discouraged to save your file in the /etc/ folder.

answer May 31, 2013 by anonymous
0 votes

That directory is protected from users for a reason. You defeat that
and risk the system.

answer May 31, 2013 by anonymous
0 votes

/etc is used to store configuration files for the operating system & if you inadvertently corrupt the wrong one then you could kill the system.

answer May 31, 2013 by anonymous
Similar Questions
0 votes

I'm trying to write a python script that writes some content to a file root through sudo, but it's not working at all. I am using:

 channel = 'stable'
 config_file = '/opt/ldg/etc/channel.conf'
 command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file]
 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 out, _ = p.communicate()

But it seems as if this isn't doing anything.

I just want to write the contents of the variable channel to the file /opt/ldg/etc/channel.conf. But whatever I try just doesn't work. Can anyone offer any pointers?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...