LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 05-13-2014, 11:07 PM   #1
tmtkobedmx8
LQ Newbie
 
Registered: Jul 2012
Posts: 6

Rep: Reputation: Disabled
Unhappy 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

Last edited by tmtkobedmx8; 05-13-2014 at 11:49 PM.
 
Old 05-14-2014, 02:50 AM   #2
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
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/

Last edited by eklavya; 05-14-2014 at 02:58 AM.
 
1 members found this post helpful.
Old 05-14-2014, 04:28 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,503

Rep: Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433
looks like duplicate of http://www.linuxquestions.org/questi...pt-4175504914/
 
Old 05-14-2014, 04:11 PM   #4
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,667
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Quote:
Originally Posted by eklavya View Post
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
 
1 members found this post helpful.
Old 05-15-2014, 01:16 AM   #5
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by Habitual View Post
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
 
1 members found this post helpful.
Old 05-15-2014, 03:24 AM   #6
tmtkobedmx8
LQ Newbie
 
Registered: Jul 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-15-2014, 01:55 PM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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/.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change password using a script file and text file? hayloiuy Linux - Newbie 5 06-27-2011 02:13 AM
Read password from AES encryption from txt file dolphs Linux - Security 5 01-19-2011 05:10 PM
How can read from file.txt C++ where can save this file(file.txt) to start reading sam_22 Programming 1 01-11-2007 06:11 PM
How to redirect txt file to password input? saravkrish Linux - General 3 04-01-2006 03:23 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration