Debian 12 Notes for Adding Included Commands to the Path Environment
This is a small note for myself or anyone else who finds they need a command in Debian 12, but get a "no command found" error.
In order to use commands like usermod, shutdown, reboot, and many others, we need to add the directory that stores these programs to the PATH Environment. Debian 12 leaves this directory out of the PATH by defaut.
Most of the programs mentioned above set in "/usr/sbin". If you type the following command into the terminal you will see /usr/sbin is not currently in the PATH.
$ echo $PATH
In order to use them without needing the FQP we will add that path and directory to the PATH. To do this we will run the following command in the terminal:
$ export PATH=$PATH:/usr/sbin
Now if we run the echo $PATH command above, we should now see /usr/sbin in the PATH.
Note: This will only last for the current shell session. If you want to make the change permanent please continue below.
To make the change to the PATH permanent we need to make a change to the ~/.bashrc file (or .zshrc if using zsh). To make this change we will use "vim" (you can use nano or other terminal editors) to open the ~/.bashrc file:
$ vim ~/.bashrc
Next we will add a line to the bottom of the open ~/.bashrc:
$ ... $ #Adding /usr/sbin to this users path $ export PATH=$PATH:/usr/sbin
Save and close the file. We now need to make sure our shell is aware of the change. To do that we run the following command:
$ source ~/.bashrc
That's it. You should now have the /usr/sbin directory in your path across each shell session.