bug-sh-utils
[Top][All Lists]
Advanced

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

Re: su command not working


From: Bob Proulx
Subject: Re: su command not working
Date: Mon, 10 Sep 2001 13:49:48 -0600

Jonathan

> According to the man page su should assume USER is root if none is
> given.
> 
> This used to work but having installed ximian it no longer does and I
> need to explicitly add -l to the command line to su to root.
> 
> If I just enter su the password is validated but I am still the original
> user that executed the su command.
> 
> Thought you might like to know - if you have time maybe you can point me
> at a quick fix?

Thanks for the report.  But I cannot recreate your problem.  And
actually I am suspicious that it is the command prompt which might be
causing confusion.

By default su only changes your user id by stacking another shell on
top of the current one and does not reload the environment files.
Bash by default will reload the .bashrc file, however.  By adding -l
you are telling su to specifically mark the shell as a login shell.
Shells which start up and are marked as a login shell will load up the
system /etc/profile, and then $HOME/.profile, etc.  Bash reads the
.bash_profile instead if one exists so that you can maintain specially
along side ksh and sh-posix, etc.

So normally if you 'su' you don't see any difference.  The command
prompt is probably exactly the same.  Which typically would include
the login name and so in this case would be the old login name.  But
if you 'su -l' you force it to read the .profile again and that
probably updates the prompt with the new information about who you
are.

Try this:

  su user
  id
  exit
  su -l user
  id
  exit

The 'id' command will print out the user and group id information.
Please verify that output.  I am hoping you will find that you really
did su to the other user in both cases.

Most people will have the PS1 command prompt string set in the .bashrc
file so that when any new shell is loaded the PS1 prompt will get
updated information.

Of course what I just said is conjecture based on the most likely
problem.  It is certainly possible that you have a real problem.  But
it seems really strange that there would be an *id* difference between
'su' and 'su -l' which is virtually the same in that respect.  The
only differnce is really very minor in the way it launches the shell
to say it is a login shell.  In that case the name changes from 'bash'
to '-bash', the starting '-' tells all shells that they are a login
shell.  Otherwise no difference.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]