hi , can anybody suggest me how can i change the context of /etc/resolv.conf from user mode
i try make a script
sudo echo "nameserver=10.1.1.1" > /etc/resolv.conf
but i get
permission denied for file /etc/resolv.conf
hi , can anybody suggest me how can i change the context of /etc/resolv.conf from user mode
i try make a script
sudo echo "nameserver=10.1.1.1" > /etc/resolv.conf
but i get
permission denied for file /etc/resolv.conf
If you understand the order in which things are done by the shell, it will be obvious.
First the current shell redirects stdout to the specified file, then it runs the command, in this case sudo blah blah. So the opening of the file is done as the current user, not as the superuser.
Think about it: Your assumed order doesn’t make sense. If it were possible to open the file for writing regardless of whether the sudo succeeds or not, then one could overwrite system files this way.
I’ll leave it to you to work out how to open the file after the sudo has taken effect.