top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

0 votes
861 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 LinkedIn 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
+1 vote

Is there a way to redirect ports 80 and 443 to 8443. I have a non root user but I cannot use CentOS firewalld nor iptables. I have tried these things. But it still fails.

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?

...