Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.
  1. Can we run the same application under different users? Ex: App1 running under both /home/usr1/App1 and /home/Usr2/App1 on a Linux platform?
  2. Can we have Same UID for two different users? Ex: /home/usr1/App1 and /home/usr2/App2 i.e Usr1 and Usr2 having same UID?? If yes then how to do it?
  3. Can an application switch from one user to another, e.g., app1 running under /home/usr1 can switch to /home/usr2
share|improve this question
3  
Hello, Welcome to askubuntu. This Q&A site is meant for ubuntu related queries. So it would be better if you ask this question in sister site like Unix Stack Exchange. Also the rule says, Don't add many queries in one question. Please a have look at FAQ. I am flagging this question for migration to Unix SE site. –  Web-E Mar 22 '13 at 6:32
    
@Web-E Why do you think this is not about Ubuntu? –  Eliah Kagan Mar 22 '13 at 8:18
    
@EliahKagan well I have the same reservation as web-e. The questions 1 and 3 are well... weird. They lack something but I can not get my finger on what it is it is lacking. –  Rinzwind Mar 22 '13 at 8:26
    
No sir, @EliahKagan I was creating an answer (but yours is better so I gave up on that ;) ) –  Rinzwind Mar 22 '13 at 8:33
add comment

1 Answer

It's best to post separate questions separately. However, since these can all be answered quickly (and are related), I've done so.

  1. The same application may be run by different users, at different times, or at the same time. The application may run from the same location (so long as both users have access to execute it), or separate copies may be run from different locations (as in your example).

  2. Two different users cannot share a UID. Your UID is actually more central to your user identity (hence the name) than your username. When you own a file or folder, the filesystem contains your UID associated with the file, not your username. Having two users with the same UID would mean having a single user with multiple names (which is also not supported).

  3. Yes, it is possible to switch user identity. You can use sudo -u other-user command... or (if you are currently root, or if the target user has login enabled and you know their password) su other-user -c 'command...'. You can invoke these commands yourself, but scripts and applications can also use them.

    See the community documentation, man sudo, and man su for more details on how this works and how to use it. In a program you are writing, you can also use the setuid function; see man 2 setuid and man 3 setuid. To run graphical applications, you should use gksu/gksudo or (in Kubuntu) kdesudo instead of invoking su and sudo directly (but please note that by default in Ubuntu gksu invokes sudo, not su). See this section of the community documentation, man gksu (covers gksudo too), and man kdesudo.

    Before writing programs or scripts that change users, I recommend reading up extensively on how user identity works in Unix-like systems.

share|improve this answer
    
Point 2 can be solved with a group ;) –  Rinzwind Mar 22 '13 at 8:32
    
@Rinzwind A group can't make multiple users have the same UID, which is the question asked. I'm not sure what the intent is, so I'm not sure if a group would do what the OP needs. But you may want to post an answer that includes information about groups. (Or if you prefer to edit this CW answer, of course feel free, but I know you had said you'd been composing an answer...). –  Eliah Kagan Mar 22 '13 at 8:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.