-1

Given 2 users in the same group

myuser:grp1
anotheruser:grp1

I have some Function key assignments in my personal .exrc file that I need to work the same way under both user logins. I have set 664 permissions to my .exrc and copied and set the other users .exrc the same way. My tmp folder has 777 permissions and is in the same group

the F10/11/12 keys specific commands from .exrc

map ^AI :1,$w! $HOME/tmp/tmp.tmp^M 
map ^AJ :'k,.w! $HOME/tmp/tmp.tmp^M
map ^AK :r $HOME/tmp/tmp.tmp^Mk    

issue:

su - anotheruser

picks up the anotheruser .exrc but is using it's local tmp folder

su anotheruser

doesn't appear to use either .exrc as the F keys are doing something totally different and returns the following error:

ex: 0602-054 No alternate file name to substitute for the # character.

I could force the anotheruser .exrc to explicitly point to my tmp folder and use su - but then there are other OS specific settings that are missing from my .profile and .kshrc files which I am not prepared to provide to the other user

0

I think this is a good use case for symlinks. (This assumes you have root access.)

Put the .exrc file somewhere world-readable. Possibly /usr/local/share/, although actually I think /usr/etc/ would be appropriate.

sudo mv -i ~/.exrc /usr/etc/

chown it to root and set the permissions to 644.

cd /usr/etc/
sudo chown root:root .exrc
sudo chmod 644 .exrc

Create a symlink in your home directory like so:

ln -s /usr/etc/.exrc ~/.exrc

And in anotheruser's home directory as well:

ln -s /usr/etc/.exrc ~anotheruser/.exrc

You will still need to use su - anotheruser or su -l anotheruser, as you can see from the man page:

   -, -l, --login
          make  the  shell  a  login  shell, clears all envvars except for
          TERM, initializes HOME, SHELL, USER, LOGNAME and PATH

Since .exrc is loaded depending on your $HOME environment variable, that needs to be set appropriately for this to work.

  • The symlink doesn't appear to solve the issue ... I get the same result for " su anotheruser " (same error with the any of F10,11 or 12 indicating that the symlink version of .exrc is not being used – bxdobs May 10 '16 at 21:01
  • @bxdobs, updated. – Wildcard May 10 '16 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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