1

I'm on OpenBSD 5.8, new to ksh and I put the string

alias su='su -'

in my .kshrc file as the only line. After logging in via ssh

alias su

gives me

su alias not found

and

$(cat .kshrc)

gives me

-' alias not found

what am I doing wrong?

5
  • alias su='su - '.oh, that's not it. ksh isn't sourcing your .rc. It needs to be put in $ENV by ssh at login.
    – mikeserv
    Commented Jan 15, 2016 at 18:57
  • okay. how do I make ssh put it in $ENV? Commented Jan 15, 2016 at 19:06
  • now I put ENV=$HOME/.kshrc in .profile. Is that what you meant? Commented Jan 15, 2016 at 19:12
  • actually yes. it still wont source it if EUID and UID dont align - but they should.
    – mikeserv
    Commented Jan 15, 2016 at 19:17
  • yes they are. if you make it an answer I'll mark it as the solution Commented Jan 15, 2016 at 19:23

1 Answer 1

1

An interactive ksh sources the file named in the environment variable $ENV at startup if its EUID and UID match and $ENV - after being subjected to shell expansions - evaluates to the name of a readable file. And so if aliases specified in your ~/.kshrc are not loaded at runtime, then it is probably because it is not being sourced, and that is probably because it is not in $ENV.

So your solution could be to put it in a file sourced before that - (such as /etc/profile or ~/.profile for ssh login shells).

echo 'ENV=~/.kshrc' >> ~/.profile
1
  • @StefanBerger - meh. votes are nice - but solving problems is better. and anyway - always be suspicious of answers with a lot of votes - especially new answers. they only get that way if everyone instantly agrees with them - and that only usually happens for stuff that is either common knowledge or stuff that those that don't know any better commonly believe.
    – mikeserv
    Commented Jan 15, 2016 at 19:42

You must log in to answer this question.

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