I'm using a server that is shared with about 7 other people. We each have our own user account, but they don't have permissions to access most of what we need, so they're essentially useless other than for authentication.

Instead, we use sudo to become a different user (called 'dev'). The dev account is shared by everyone on the team, and a few others from a different team. Considering that this is the only account we have access to that has enough privileges to actually do work, it's very frustrating having to share it.

I have my own directory under dev's home directory. What I would like to do is be able to open a new shell session with my subdir as HOME, and source dotfiles from my subdir rather than from dev's HOME. That way I could have my own settings (.bashrc, .vimrc, etc.), I wouldn't be digging through other people's .bash_history when I press up and they wouldn't dig though mine.

I know I can kind of fake this by changing the HOME directory and sourcing dotfiles as needed, but I'd like a way to do this automatically when I sudo to the shared account, something like: sudo -ui dev HOME=/users/dev/me bash (this doesn't work as-is). Is there a way to do this?

I know the 'correct' solution is to not use a shared account in the first place, and give proper permissions to each user's account, but the server is owned and operated by a separate company, and their sysadmins have been adversarial to changes suggested by our group. We actually used to have a lot more access and tools available, but it was stripped when they found out that we were doing things they didn't want us to (nothing against contract or even unusual - the sysadmin is just petty)

  • If your only concern is creating & editing files you might consider putting all of the developers in a single group and set the permissions (recursively) on the directories to 02770. Files can be modified and/or created with all group members having access. I would hope that the foreign sysadmins would not be opposed to a simple permissions change.
    – doneal24
    May 25 at 18:56
  • Assume that I don't have any influence over the sysadmin. My managers are working with the other company and trying to go over the sysadmins head to get a saner setup. This isn't the only problem we've had with them. In the meantime, I still need to get work done, and just would like a little quality-of-life enhancement
    – foxbeard
    May 25 at 19:02
  • Are you able to run sudo -i -u dev; chmod 02770 .. If so, you then only need to convince the sysadmin to put you all in the same group.
    – doneal24
    May 25 at 19:08
  • 1
    If the company's work is being impeded by their choice of the hosting service, I would suggest contacting the powers-that-be to say that employee productivity would be increased by choosing a different provider.
    – doneal24
    May 25 at 20:03

1 Answer 1


It's not quite as automatic as I would like, but this is what I came up with:

sudo -iu dev bash # change to dev and start the session in bash instead of sh (the default for the dev user)

. me/rehome.sh # source the script below to change HOME


export HOME=/home/dev/me # reset the HOME var.
export HISTFILE=$HOME/.bash_history # change the bash history file to my own

history -c; history -r # Clear the session's history (loaded from the shared account), and then load my own

. $HOME/.bashrc # source my .bashrc settings

cd $HOME

This makes it so vim and other programs I launch can will use dotfiles from my directory rather than dev's and gives me my own shell history so I don't have to scroll through the rest of the team's and they don't have to see mine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .