# Getting SU to have the Same $PATH as Root

## elboricua

Hello all.  I am trying to get su to have the same $PATH as root.  Right now if I log in as root, I can get to commands like shutdown, kdm etc.  If I login as a user and then su to root and I try command I get an error bash shutdown not found.

I copied everything in root to /etc/skel and I created a new user who was a member of the wheel group.  Well now the user has th right path.  If I try shutdown (of course I get the you must be root to do that mesage).  If I su after that and try shutdown -r now I get that same bash shutdown not found.

Any ideas on how to get su to have the same $path as root?  As an interim solution I made a copy of roots $PATH and when I su I have a mini script that I made that basically does export $PATH=:/same/as/what/root/has

Is there a way to do this without having to do the extra step of adding export $PATH ?  I have tried adding export $PATH into the users .bashrc and it does not work when I su.  I am stumped.

----------

## rogue

just do the command 'su -'

the - means the user you are changing to, in thsi case root, has it's environment take over the shell.

----------

## elboricua

Cool tip thank you!!  I put 

alias su='/bin/su -'

into my .bashrc file

----------

## BoBB

is there a way to have 'su-' not go to roots home directory? when i used debian su would stay in working directory and have roots PATH and i kinda got used to it. Is there a way to do that?

----------

## stixx

The point of using su - <user> is that you receive the entire environment of that user you are becoming.  If you dont want to change to the other home directory just use su then source ~<user>/.profile or .bash_profile or whatever shell they are using  :Smile: 

----------

