LinuxQuestions.org
Review your favorite Linux distribution.
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


Reply
  Search this Thread
Old 11-23-2010, 06:56 AM   #1
hellomythili
LQ Newbie
 
Registered: Jun 2010
Posts: 7

Rep: Reputation: 0
changing a file at a time located in two locations


Hi.
Iam very new to linux.
suppose i have two file with same name fstab one file is located in /etc and the other is located in /root/
If i make a change in /etc/fstab file the changes has to reflect in /root/fstab .
Is there any command to do this?
Kindly help me...

Mythili
 
Old 11-23-2010, 07:01 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Is the file in /root intended to be a backup of the file in /etc?

If the file in /root is NOT intended to be a backup of the file in /etc then you can actually have only one file and create the illusion of having a second file. Use file links to create this illusion.

First remove the real file in /root.
Code:
rm /root/fstab
Next create a directory entry in /root that points to the /etc/fstab file.
Code:
ln /etc/fstab /root/fstab
You will only have one real file but there will be two directory entries pointing to the file. One directory entry is in the /etc directory while the other directory entry is in the /root directory.

Last edited by stress_junkie; 11-23-2010 at 07:05 AM.
 
Old 11-23-2010, 07:10 AM   #3
hellomythili
LQ Newbie
 
Registered: Jun 2010
Posts: 7

Original Poster
Rep: Reputation: 0
I tried with ln ,ln -s but if i make changes in /etc/fstab that are not showing in /root/fstab
I need that to happen
 
Old 11-23-2010, 07:18 AM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Open a terminal window.
Code:
cd /root
rm fstab
ln /etc/fstab fstab
Copy the commands and whatever happens from the terminal window and post it here.
 
Old 11-23-2010, 07:26 AM   #5
hellomythili
LQ Newbie
 
Registered: Jun 2010
Posts: 7

Original Poster
Rep: Reputation: 0
ln /etc/fstab /root/fstab
ln: creating hard link `/fstab': File exists
In /etc/fstab has some content but in /fstab is empty file.
 
Old 11-23-2010, 08:43 AM   #6
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by hellomythili View Post
ln /etc/fstab /root/fstab
ln: creating hard link `/fstab': File exists
In /etc/fstab has some content but in /fstab is empty file.
You didn't remove the original file in /root first.

I think at this point you should create a backup of /etc/fstab. Please do this before going any further.
Code:
cp /etc/fstab /etc/fstab.original
Now please follow the instructions that I provided in the previous post including the rm instruction.

When someone asks you to copy what you see in a terminal window that means to highlight that part of the terminal window, click the right hand mouse button, select copy, bring the mouse to the post that you are creating here, press the right hand mouse button, and select paste.

Last edited by stress_junkie; 11-23-2010 at 08:46 AM.
 
Old 11-24-2010, 12:09 AM   #7
hellomythili
LQ Newbie
 
Registered: Jun 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you very much ,it works for me...
 
  


Reply


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
reading changing file in real time KBriggs Linux - Newbie 2 05-27-2010 10:03 AM
PAM time restrictions - changing Time.conf so it gets time from sql table noodlesoffire Linux - Newbie 1 04-04-2010 05:41 PM
Yum update complains missing file (broken dep), but file can be located. davidas Linux - Software 0 03-27-2004 10:11 PM
File Locations stodgel Linux - General 1 06-13-2003 09:02 AM
File locations peeples Linux - Distributions 5 10-04-2002 03:26 AM


All times are GMT -5. The time now is 03:58 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