Wednesday, October 10, 2012

How to grant permissions to edit etc/hosts file to all users

If you want to grant permissions to edit /etc/hosts file to all users without granting root permission,this is the simple way to do that.
log in to the system from root user and just enter,
"chmod a+w /etc/hosts"

Ex :

$ ls -la /etc/hosts
-rw-r--r-- 1 root wheel 236 Sep 23 2007 /etc/hosts
$ cat >> /etc/hosts
-bash: /etc/hosts: Permission denied
$ su admin
Password:
$ sudo chmod a+w /etc/hosts
Password:
$ exit
logout
$ ls -la /etc/hosts
-rw-rw-rw- 1 root wheel 241 Mar 9 15:37 /etc/hosts
$ cat >> /etc/hosts
test
$ tail -1 /etc/hosts
test

More infomation available at 
http://hintsforums.macworld.com/archive/index.php/t-99568.html 

No comments: