You can't get root privileges inside the script: it is very insecure. You should write instead Code: import os os.system('echo 78 > /abc/abc/bca') or even better Code: open('/abc/abc/bca', 'w').write('78') and run this script with root privileges
import os os.system('echo 78 > /abc/abc/bca')
open('/abc/abc/bca', 'w').write('78')