After using the command su (without any option) on a Debian 12 server, a junior administrator tries to run several system utilities:
# ifconfig
bash: ifconfig: command not found
# reboot
bash: reboot: command not found
# echo $PATH
/usr/local/bin:/usr/bin:/bin
A quick check shows that /usr/sbin/ifconfig and /sbin/reboot are present on the filesystem. Which action will most quickly restore access to these commands for the current root session and prevent the PATH problem from recurring when switching users in the future?
Append /usr/local/sbin to PATH in /etc/profile and reload the file with source /etc/profile.
Run chmod 755 /usr/sbin/ifconfig and chmod 755 /sbin/reboot to make the utilities executable.
Exit the current shell and re-enter the root account with su - so the full login environment (including /usr/sbin and /sbin) is loaded.
Execute ldconfig to rebuild the shared-library cache used by binaries in /usr/sbin and /sbin.
Invoking su - (or the equivalent su --login or sudo -i) starts a login shell for the target user. Login shells read the same startup files that are processed at an actual login and therefore apply the PATH defined for root in /etc/login.defs (ENV_SUPATH) and other profile scripts. This adds /usr/sbin, /sbin, and often /usr/local/sbin to the beginning of the PATH, allowing root-only utilities such as ifconfig, reboot, and many others to be located without typing absolute paths.
Using chmod will not help because the binaries are already executable; ldconfig only refreshes shared-library links and caches, not PATH; and adding a directory like /usr/local/sbin to /etc/profile would not fix the immediate session and would still omit /sbin and /usr/sbin unless those were added explicitly. Therefore starting a proper login shell with su - is the correct and fastest fix.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
Why does `su -` load the full login environment?
Open an interactive chat with Bash
What is the purpose of `PATH` and why does it exclude certain directories by default?
Open an interactive chat with Bash
What is the difference between `su` and `su -` in Linux?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Troubleshooting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access