why is /usr/sbin not in root's path?
I've been using debian bullseye for a while now and noticed that /usr/sbin is not by default in root's path, contrary to other distros. This leads some (third-party) scripts to fail, for instance because they cannot find ldconfig. What, if any, would be the reason debian ommits /usr/sbin from root's path?
Code:
$ whoami |
I used to use the following at windows (CYGWIN bash.exe)
~/.bashrc file: Code:
$ /usr/bin/gawk.exe '{ if( ( 8 <= NR ) && ( 11 >= NR ) ) { print $0 } }' ~/.bash_profile Code:
if [[ -d /usr/sbin ]] |
I am guessing you are using su to login as root. su still uses the user's path environment but su - switches to root's environment. debian does not add /usr/sbin to the user's path while others do.
|
Yes, if you are switching to root using su then you will need the -l option to start with an environment similar to a real root login.
|
Indeed, I was using su without flags, thanks for clarifying.
- debian does have /usr/sbin in root's path (but not in a user's path) - su without -l preserves that user's environment |
Quote:
In Debian, my method is to set the $PATH variable early in ~/.profile as follows: Code:
# ~/.profile: executed by the command interpreter for login shells. Even when the path is set as above, you should still su to root as follows in order to use root's environment: Code:
$ su -l |
The reason that certain utilities and system programs aren't directly in the root or super users' path is because the /sbin folder is a symbolic link back to the user sbin folder.
|
~/.bashrc or ~/.mkshrc or ~/.kshrc for all users including root
Quote:
I should have added following code inside ~/.bashrc or ~/.kshrc or ~/.mkshrc based on different OS for all users including root user Code:
OS=$(/usr/bin/uname -s 2>&1 | /usr/bin/sed "s/-[0-9]*\.[0-9]*\-[0-9]*//;") |
The user's path isn't what changed, "/usr/sbin" has always been in the root path only.
What did change is the behavior of su. Quote:
|
Thanks jens, that really explains it
|
All times are GMT -5. The time now is 08:31 AM. |