LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   changing a file at a time located in two locations (https://www.linuxquestions.org/questions/linux-newbie-8/changing-a-file-at-a-time-located-in-two-locations-846001/)

hellomythili 11-23-2010 05:56 AM

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

stress_junkie 11-23-2010 06:01 AM

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.

hellomythili 11-23-2010 06:10 AM

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

stress_junkie 11-23-2010 06:18 AM

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.

hellomythili 11-23-2010 06:26 AM

ln /etc/fstab /root/fstab
ln: creating hard link `/fstab': File exists
In /etc/fstab has some content but in /fstab is empty file.

stress_junkie 11-23-2010 07:43 AM

Quote:

Originally Posted by hellomythili (Post 4168101)
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.

hellomythili 11-23-2010 11:09 PM

Thank you very much ,it works for me...


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