Share configuration files between two users

1

1

I have a program which will be used by two users. It saves it data in $HOME. Is it possible to share the config files (or only one of them - the database) between two users?

My idea was a symlink. The config files have 0644 permissions, though, so only a symlink won't be a solution. If using a symlink is the best solution, what's the optimal permission setup, so that only these two users can have a write access to the config files.

I'm using Linux Mint 17 (Ubuntu derivative)

marmistrz

Posted 2014-08-31T10:08:23.093

Reputation: 455

Answers

1

Make the file mode 0664 and then chgrp the file to a group containing both users. If there's no such group, you'll have to create one (with groupadd) and then add the users to it (usermod --append --groups) before logging each user out and back in.

aecolley

Posted 2014-08-31T10:08:23.093

Reputation: 342

1

While it may be technically possible to do this, you have to consider the implications.

What if user A is logged on and using the application and then user B logs in and starts using the application? If both change something in the application which needs to be written to the database, which one takes precedence?

Chances are that if the application isn't designed for this that both will try to write to the database and corrupt it and you'll then end up in the situation where nobody can access it. Or at best, one will 'win' and the other user's work will be lost.

So the bottom line is - check whether the application is designed for this. If not, you're running a risk of corrupting or losing something.

garethTheRed

Posted 2014-08-31T10:08:23.093

Reputation: 2 520

But they won't write at the same moment. It's one computer, so only one users can perform an action at a time. – marmistrz – 2014-08-31T17:20:41.077

No! One user could be on the computer and the other could be logging in remotely. If you're certain that it will only be shared by users physically logging on the computer then that will decrease the risk considerably. Only you know the details as you haven't written them in your original Question. – garethTheRed – 2014-08-31T17:36:09.220