jonhadfield / python-hosts

a hosts file manager library written in python
MIT License
125 stars 33 forks source link

Permission denied: '/etc/hosts' #21

Closed robooo closed 5 years ago

robooo commented 5 years ago

How to deal with: PermissionError: [Errno 13] Permission denied: '/etc/hosts' when I can't change perms on hosts file? (default ubuntu setting)

jonhadfield commented 5 years ago

Unfortunately, Linux distributions tend to have 644 permissions on /etc/hosts where only root has write access. You should be able to read it as any other user though, unless someone has changed the default permissions.

If you just want to test with a different file, you can specify a custom path: hosts = Hosts(path='my_hosts_file')