When a user performs an su command, /bin gets added to the users PATH before /usr/bin.
When switching to another user with
su, the PATH includes /bin by default:
# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin # su --login user $ echo $PATH /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/user/.local/bin:/home/user/bin
From the man page, we can read:
-, -l, --login Start the shell as a login shell with an environment similar to a real login: o clears all the environment variables except TERM o initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH o changes to the target user's home directory o sets argv of the shell to '-' in order to make the shell a login shell
- Red Hat Enterprise Linux 7
- su, login
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.