su subshell

Joe <[email protected]> Fri, 18 Sep 2009 04:34:26 +0800
Newsgroups org.kernel.vger.linux-config
Message-ID <[email protected]>
Hi,

I met a strange behavior of su command with "-". I login my host as
root and want to run some command with normal user, say joe. Here is
what I see:

[root@stone]# su - joe -c ls
[joe@stone]$                                        <===== Instead of
list the files under this directory, the shell login the account joe
[joe@stone]$ exit
Desktop Music                                      <===== When I type
exit in the subshell, it prints the output of "ls" command and then
return to root
[root@stone]#




If not speficying "-", everything works fine:
[root@stone]# su joe -c ls
Desktop Music
[root@stone]#


Any ideas? Am I missing something?


Thanks in advance,
Joe