Before I forget again: the correct syntax to run a <command> as <user_x>, with the same login-environment as when user_x logs-in (preloading ~/.bashrc, … ) is
In case you want to “switch” to another user (as a login) then the proper way would be to
More info, see “man sudo” and “man su”
Just rented a Vps machine running ubuntu 12.04 lts 32bits… its virtualized with KVM, promissing 512MB Ram, 10GB HDD and 1TGB bw… for 3€/month with a promo until 6/01/2013 (what a bargain!) I can only think they are setting up the VPS service and need “testers”… the site itself is almost naked… and in less than a day, I’ve already experienced the first network-cuttof… but somehow it rocks for a “hobby” server
Well, I’m very excited… a lot to play bound only by imagination limits 🙂
I’ll leave here some notes about what I did
Well, I’m overthrilled!!!!
…and a few other files
This method is not reliable- inside the .rvm folder, there are files which contain the pathnames (which contain the original user-name “user-x“) hardcoded inside.
See erhard karger comment which explains it, as he tried to clone the .rvm directory
user-x has RVM instaled in it’s home folder, with severall ruby versions, and severall gemsets… all goes well and he is very happy – he has everything very well setted up!
user-y does not have RVM installed, and he would like to have everything user-x has: the RVM, the rubys, the gemsets, the configuration tweeks… everything as user-x
user-y could start to install the RVM, and then proceed to install the same ruby versions, and the same gems, etc… to end up with an instalation similar to that of user-x, that would end up to be same after some time.
But, there is a simpler solution: user-y can simply ask user-x to give him a full copy of the following files/directories from his $HOME:
files: .bashrc, irbrc, .gemrc
And by simply copying those from the /home/user-x into /home/user-y it is possible to have all the RVM cloned from user-x to user-y.
– really easier/faster than to install ruby, gems, and install all step by tep…
– this can be used to make backups of the RVM installation
hope it helps someone – if it does, drop a comment 🙂
Note that this method is NOT FIABLE! Nonetheless, this worked for me – that was the reason why I wrote the post. I used a Ubuntu box, with 2 users that belonged both to a same group – and copied and changed user-ownership of the copied files, and everything worked… but now it just seems a miracle 🙂 (although it keeps working!)
Final line is: worked for my particular case, but it’s not a general or recommended method at all…
If you use multiple Ruby versions, with multiple ruby gems for each version (for compatibility), then you *need* to learn about RVM, the Ruby Version Manager.
RVM in short will make it very easy to install any of the many ruby versions, just by indicating the version (it will download, compile, etc…).
Plus, it can also manage separate “gemsets” which are groups of gems, so that you indicate which gemset you want the ruby to see/use.
And it can make it all within a user account, without the need to do any “system-wide” install (no sudo’s) – so why not give it a try?
I’ve installed it for the first time (very easy), and never more went back – do recommend.