DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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
What, if any, would be the reason debian ommits /usr/sbin from root's path?
Absolutely no idea, but it's just annoying. There are certain commands in /sbin you may want to run as a normal user (such as ifconfig).
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.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
[...]
Log out and back in.
Even when the path is set as above, you should still su to root as follows in order to use root's environment:
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:
Originally Posted by cmk77
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
if I am facing this issue:
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]*//;")
case $OS in
"Linux")
if [[ -f /usr/bin/grep ]]
then
EGREP="/usr/bin/grep -E"
elif [[ -f /usr/bin/egrep ]]
then
EGREP="/usr/bin/egrep"
fi
;;
"SunOS")
if [[ -f /usr/bin/grep ]]
then
EGREP="/usr/bin/grep -E"
elif [[ -f /usr/bin/egrep ]]
then
EGREP="/usr/bin/egrep"
fi
;;
"AIX")
if [[ -f /usr/bin/grep ]]
then
EGREP="/usr/bin/grep -E"
elif [[ -f /usr/bin/egrep ]]
then
EGREP="/usr/bin/egrep"
fi
;;
"HP-UX")
if [[ -f /usr/bin/grep ]]
then
EGREP="/usr/bin/grep -E"
elif [[ -f /usr/bin/egrep ]]
then
EGREP="/usr/bin/egrep"
fi
;;
"CYGWIN_NT")
if [[ -f /usr/bin/grep ]]
then
EGREP="/usr/bin/grep -E"
elif [[ -f /usr/bin/egrep ]]
then
EGREP="/usr/bin/egrep"
fi
;;
*)
#echo use related path to grep
if [[ -f /usr/bin/grep ]]
then
EGREP="/usr/bin/grep -E"
elif [[ -f /usr/bin/egrep ]]
then
EGREP="/usr/bin/egrep"
fi
;;
esac
if [[ -d /usr/sbin ]]
then
echo $PATH 2>&1 |\
$EGREP "^/usr/sbin:|:/usr/sbin:|:/usr/sbin$" >/dev/null 2>&1
Ret=$?
if [[ 0 -ne $Ret ]]
then
export PATH="/usr/sbin:$PATH"
else #DEBUG01
echo "\$PATH having /usr/sbin" #DEBUG02
fi
else #DEBUG03
/usr/bin/ls -ltrd /usr/sbin #DEBUG04
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.