I want to have the same folder at two different locations in my Ubuntu. If I update something in one, it should also get updated in the other location.
How can I make it happen?
Use bind mounts.
Suppose you have an existing directory
want to mirror it to
/home/pandey/mirror so that everything you
do in either of them is automatically done in the other one as well.
This doesn't require any syncing or copying between the two directories. A bind mount is just another view to the original directory and what happens in one also happens in the other.
Create (as your user) the new directory
bind-mount the original directory to the newly created path. This requires root access:
sudo mount --bind /home/pandey/original /home/pandey/mirror
To undo this, simply
sudo umount /home/pandey/mirror rmdir /home/pandey/mirror
See also this question and its outstanding self-answer over on stackexchange about bind-mounts.
As pointed out in the comments but not as a proper answer:
In many cases, a symbolic link is the easiest solution.
You can create them easily on the command line (using the
ln command with
You can create them easily using a GUI as well: Most file browsers (nautilus, ...) let you create a symbolic link using drag and drop (like for moving a file) while holding down a modifier key (CTRL+SHIFT).
Example for command line usage:
$ mkdir first_dir $ ln -s ./first_dir ./second_dir $ ls first_dir second_dir $ touch ./first_dir/test_1 $ touch ./second_dir/test_2 $ ls ./first_dir test_1 test_2 $ ls ./second_dir test_1 test_2
You can do it by setting a crontab job:
iin order to activate the insert mode of your vim editor.
You can enter the command you want to be done there, so you can copy all files of the folder in another folder. For example, if you want to copy all files in
/home/user/public you should insert this command in your
rsync /home/user/folder_name -r /home/user/public
This will copy all files in the desired interval. If you want to copy all files at 21:30 every day your edit should be:
30 21 * * * rsync /home/user/folder_name -r /home/user/public
For more information about crontab look here or use