[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Email based attack on University



On Tue, Oct 15, 2019 at 11:13:00AM +1100, Keith Bainbridge wrote:
> I have an issue trying to run an alias. I get 'alias' not found error. So I
> sym-linked my .bashrc into /root. Same result.

... huh?

> If I su, get # prompt and 'alias' works.  Typing alias gets list as
> expected. exit. Try su -c and same results. exit.
> 
> su -c "alias" - not found.

Well, of course.  su -c runs a noninteractive shell.  Noninteractive
shells do not read your aliases, because they don't read ANY shell
startup files.  In addition, noninteractive *bash* shells disable
alias expansions.  Because no sane person wants aliases interfering
with a script.

> So where do I put .bashrc for a su - "alias" to work, please.

I'm not sure I understand your intention.  You want an alias to work
in some sort of scripted "su username -c '...'" command?  Well, stop
expecting that.

If you want to use a command of your own devise in a script, create
that command as a script.  Put it in /usr/local/bin and make it
executable.  Then you can use it in other scripts, which includes
sh -c or su -c invocations.

> Should I have started a new topic?

Probably, but... meh.


Reply to: