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

BIBHU DAS b13das91 at gmail.com
Fri May 31 05:12:58 EDT 2013


I am a python novice;request all to kindly bear with me.

fd = open('/etc/file','w')
fd.write('jpdas')
fd.close()


The above snippet fails with:

Jagannath-MacBook-Pro:~ jpdas$ python testUmask.py
Traceback (most recent call last):
  File "testUmask.py", line 3, in <module>
    fd = open('/etc/file','w')
IOError: [Errno 13] Permission denied: '/etc/file'


Any Idea how to create a file in /etc as non-root user?Can i use umask or chmod.......confused



More information about the Python-list mailing list