LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can my script change my hosts file and fetch the password in a txt file i have (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-my-script-change-my-hosts-file-and-fetch-the-password-in-a-txt-file-i-have-4175504911/)

tmtkobedmx8 05-13-2014 10:07 PM

How can my script change my hosts file and fetch the password in a txt file i have
 
I am trying to change my /etc/hosts with /etc/hosts.template

the command i'm running is

sudo echo "/etc/hosts.template" > /etc/hosts < password.txt

I keep getting /etc/hosts : permission denied


Any help will be very appreciated. Thanks

eklavya 05-14-2014 01:50 AM

You can rename it.
Quote:

sudo mv /etc/hosts.template /etc/hosts
If you want to put data of password.txt into /etc/hosts
Quote:

sudo sh -c 'cat password.txt >> /etc/hosts'
I hope you have back up of original /etc/hosts.

Please do not create duplicate threads.
http://www.linuxquestions.org/questi...pt-4175504914/

pan64 05-14-2014 03:28 AM

looks like duplicate of http://www.linuxquestions.org/questi...pt-4175504914/

Habitual 05-14-2014 03:11 PM

Quote:

Originally Posted by eklavya (Post 5170487)
You can rename it.
...
Please do not create duplicate threads.
http://www.linuxquestions.org/questi...pt-4175504914/

Sounds like a Virtual Host|Machine.
I wouldn't rename that file, personally

eklavya 05-15-2014 12:16 AM

Quote:

Originally Posted by Habitual (Post 5170944)
Sounds like a Virtual Host|Machine.
I wouldn't rename that file, personally

Ok, then copy it :)
Code:

sudo cp /etc/hosts.template /etc/hosts

tmtkobedmx8 05-15-2014 02:24 AM

Thanks everyone for the suggestions.
Quote:

sudo cp /etc/hosts.template /etc/hosts
did the trick and i had to run the script as sudo so i didn't have to be prompted all the time.

Tmtkobedmx8

colucix 05-15-2014 12:55 PM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of https://www.linuxquestions.org/quest...pt-4175504914/.


All times are GMT -5. The time now is 02:01 PM.