Path as "su" doesn't equal path as root or as login user

Path as "su" doesn't equal path as root or as login user

Post by Kurt Tapp » Thu, 28 Jun 2001 02:11:34



If I login as me, my path is set as defined in my .profile.  If I login
as root, my path is set as defined in /.bashrc.  No problems.

BUT if I login as me, and then "su", my path becomes
"/usr/sbin:/usr/bin" (determined by using "which").

Where is this set (under Solaris 7)?

Thanks,
-Kurt

--
Kurt Tappe
Manager, Information Technology
Associates Graphic Services
Wilmington, DE

 
 
 

Path as "su" doesn't equal path as root or as login user

Post by CH » Thu, 28 Jun 2001 03:37:40


Try
su -


Quote:> If I login as me, my path is set as defined in my .profile.  If I login
> as root, my path is set as defined in /.bashrc.  No problems.

> BUT if I login as me, and then "su", my path becomes
> "/usr/sbin:/usr/bin" (determined by using "which").

> Where is this set (under Solaris 7)?

> Thanks,
> -Kurt

> --
> Kurt Tappe
> Manager, Information Technology
> Associates Graphic Services
> Wilmington, DE


 
 
 

Path as "su" doesn't equal path as root or as login user

Post by david.mosci.. » Thu, 28 Jun 2001 03:38:06



> If I login as me, my path is set as defined in my .profile.  If I login
> as root, my path is set as defined in /.bashrc.  No problems.

> BUT if I login as me, and then "su", my path becomes
> "/usr/sbin:/usr/bin" (determined by using "which").

> Where is this set (under Solaris 7)?

> Thanks,
> -Kurt

> --
> Kurt Tappe
> Manager, Information Technology
> Associates Graphic Services
> Wilmington, DE

hi,

It's set in /etc/default/su

David.

 
 
 

Path as "su" doesn't equal path as root or as login user

Post by EB » Thu, 28 Jun 2001 06:25:21


If you do "su - root", instead of just "su", then you'll have the same path
as the root's path.


Quote:> If I login as me, my path is set as defined in my .profile.  If I login
> as root, my path is set as defined in /.bashrc.  No problems.

> BUT if I login as me, and then "su", my path becomes
> "/usr/sbin:/usr/bin" (determined by using "which").

> Where is this set (under Solaris 7)?

> Thanks,
> -Kurt

> --
> Kurt Tappe
> Manager, Information Technology
> Associates Graphic Services
> Wilmington, DE

 
 
 

Path as "su" doesn't equal path as root or as login user

Post by Aleksandar Milivojevi » Thu, 28 Jun 2001 15:07:15



> If I login as me, my path is set as defined in my .profile.  If I login
> as root, my path is set as defined in /.bashrc.  No problems.

> BUT if I login as me, and then "su", my path becomes
> "/usr/sbin:/usr/bin" (determined by using "which").

> Where is this set (under Solaris 7)?

Look into /etc/default directory.  There are two files, login and su
and in both of them you will find lines for defining PATH and SUPATH
variables (commented by default, but with default values).  They set
default path for all login shells when you log in (PATH), and default
path when you "su" (SUPATH).  Be aware that login and su are not shell
scripts.  They have similar syntax for setting variables and for
comments like shell scripts and that is it.

/etc/profile and your .profile are executed when you log in, and if
you set PATH there it will override the path defined in
/etc/default/login.  When you "su", .profile is not executed and path
remains as it was defined in /etc/default/su.  IMHO, login and su
files in /etc/default directory (in combination with
/etc/dt/config/Xconfig file) are much better place to put system wide
default path than shell initializaiton files (like /etc/profile for
example) because it works for all login shells.

--

Opinions expressed herein are my own.
Statements included here may be fiction rather than truth.

 
 
 

1. set path = "$path" hoses path in tcsh -- why???

All:

  % echo $path
  /usr/local/bin /usr/pubsw/bin /usr/bin ...
  % ls
  [... etc ... it works]
  % set path = "$path"   *** What the hell happens here??? ***
  % echo $path
  /usr/local/bin /usr/pubsw/bin /usr/bin ... looks the same
  % ls
  ls: Command not found.

This is just a particularly egregious illustration of the problem. In
general, if I try to do something like this:

  % set savedPath = "$path"  # Save current path
  % set path = "$savedPath"  # Restore saved path

it doesn't work. The path *looks* the same, but the shell can't find
anything. Recall that the shell variable path and the environment
variable PATH are linked, so setting one automatically sets the other
also. Some unexpected feature of list interpolation perhaps? Bug or
feature, I call it a pain...

Andrew Duncan

2. source control tool

3. How to expand paths in $PATH like "~/bin" to full path?

4. Backspace and Delete key

5. Secure CGI Path Access (translate file path "/" to user homedir)

6. Adding a Modem

7. "Login" and "su" issue with root password

8. XFree86, KDE & PS/2 mouse!!!

9. .cshrc path problem: "ridiculously long path truncated!"

10. PATH set by "rsh localhost echo \$PATH"

11. $PATH doesn't "stick"

12. su - doesn't give me root's path

13. zsh's 'typeset -U path' wipes out path/PATH