2

My shell bash gives me a bash : ... : command not found error and I don't know how to start to solve it. Also I had no idea witch tags should be selected except "bash" "Debian".

I'm root, also those two programs are already installed. The OS is Debian Buster and freshly installed. During the process of installation I unticked all the option in Tasksel configuration step. I think is more linked to my Shell.Later, I use to install Awesome tiling windows.

Here the ouput for my path: root@machine:~# echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Here two examples: First I tried to run the program. Second, I check if the program is installed.

root@machine:~# modprobe --verbose
bash: modprobe: command not found

root@adrien:~# apt-get install kmod 
Reading package lists... 
Done Building dependency tree
Reading state information... 
Done kmod is already the newest version (26-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

root@machine:~# openvpn 
bash: openvpn: command not found

root@adrien:~# apt-get install openvpn 
Reading package lists... Done Building dependency tree
Reading state information... 
Done openvpn is already the newest version (2.4.7-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
6
  • 3
    It's probably your PATH, try PATH=$PATH:/sbin Mar 12, 2020 at 0:22
  • 2
    Please include the output of echo $PATH
    – cutrightjm
    Mar 12, 2020 at 0:36
  • Just try upgrade your system everything.
    – Tamil
    Mar 12, 2020 at 2:11
  • How did you switch to root?
    – annahri
    Mar 12, 2020 at 4:22
  • root@machine vs root@adrien good attempt to hide your hostname, but you need to cover all instances :) or it happened on its own? Mar 12, 2020 at 12:12

4 Answers 4

5

Check your $PATH and see whether these programs are in it.

$ echo $PATH

should show what is your system search path. Compare it with what

$ dpkg-query -L <package_name>

will show you.

$ command -v program

will tell you full/absolute path to the program.

If you can't find it this way try:

find /sbin modprobe
find /usr/sbin modprobe

Modprobe resides in /sbin (or it might be in /usr/sbin) and is symbolic link to /bin/kmod. If you don't have path to directory where modprobe is you won't be able to use it unless you provide full path like $ /sbin/modprobe.

You can send result of $ set | grep PATH and we may see what's wrong with it.

As your output PATH indicates you don't have /sbin and /usr/sbin in it, you have to add it in your $HOME/.bashrc. To test it first use:

$ export PATH=$PATH:/sbin:/usr/sbin

and check whether it works. If so then add it to $HOME/.bashrc and if you want it to be available for every user add it to /etc/profile as @GAD3R suggested.

PS. $ is command prompt, you don't put it in the console, it shows that command is used in shell. In general, for regular user $ is used as shell prompt indicator and # for root. Because it can be general problem, not only root, I used $. Bear in mind that in your case when you're root $ "becomes" # but as you're already logged in as root it won't change anything.

3
  • Here is the output: root@adrien:/# echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games. There tow missing: /sbin and /usr/sbin.
    – ladentbleu
    Mar 12, 2020 at 21:43
  • Here is the output of root@machine:~# set | grep PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games TERMINATOR_DBUS_PATH=/net/tenshu/Terminator2 XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 If I remember well: # is for administrator and $ for user.
    – ladentbleu
    Mar 12, 2020 at 21:54
  • 1
    You have to add /sbin and /usr/sbin to your path, first try this: # export PATH=/sbin:/usr/sbin:$PATH. If it works add these paths to your PATH in /root/.bashrc (PS. Yes, $ is for regular user, # for root., also $ sudo command would be equivalent to # command )
    – tansy
    Mar 13, 2020 at 1:11
4

Note that Debian switched to another branch of the su command in Debian 10 ("Buster"). Unlike in previous versions of Debian, it no longer automatically adds /sbin, /usr/sbin and /usr/local/sbin to your $PATH automatically when you use plain su to become root.

This has surprised quite a few people.

You can use su - instead to explicitly fully re-initialize the environment when switching to the root user: this will cause the .../sbin directories to be included in $PATH.

Alternatively, you can automate the addition of the directories to $PATH whenever you become root, as suggested in GAD3R's answer.


Also I noticed the fact that I can reboot my computer with:

root@machine:~# reboot

instead of.

root@machine:~# systemctl reboot

(Note: the convention on Stack Exchange is to ask just one question on each question post. Multi-questions like this will make it harder for other people with the same problem to find applicable answers.)

This is a compatibility wrapper that allows you to still use the classic SysV style shutdown/reboot commands, which may be deeply embedded in the muscle memory of many long-term Linux/Unix administrators.

2
  • Ok, I got it. Il will erase it from my post. What is your advise because I think this is a symptom.
    – ladentbleu
    Mar 13, 2020 at 19:27
  • In Debian Buster, that is normal if you have the systemd-sysvpackage installed. There is a symbolic link /sbin/reboot -> /bin/systemctl, so if you used su - or sudo -i to become root or added /sbin to your $PATH any other way, you can just run reboot. The systemctl command will check its $0 and see it's being called as the "reboot", and will do just that, to maintain compatibility with the old SysV-style reboot command. The commands halt, shutdown and poweroff will work the same way.
    – telcoM
    Mar 14, 2020 at 17:57
1

You can check the location of the executable : $ which modprobe and $ which openvpn

With su the commands are

# /usr/sbin/modprobe
# /sbin/openvpn

With su - it becomes

# modprobe
# openvpn

I.e. only su - will provide full root privileges / root's PATH. Which is required for some /sbin/ and /usr/sbin/ commands: Debian 10.

1
  • The last version of Debian Administrator's Handbook is from 2015, I will read the last one because I'm not up to date.
    – ladentbleu
    Mar 14, 2020 at 14:59
1

Edit your /etc/profile as follows (the first 6 lines):

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

Then reboot your system.

3
  • It was already wrote it.
    – ladentbleu
    Mar 12, 2020 at 21:46
  • 1
    @ladentbleu from the output of echo $PATH, /usr/sbin isn't in your root PATH.
    – GAD3R
    Mar 12, 2020 at 21:51
  • What is the process that generate the past when the machine is starting ?
    – ladentbleu
    Mar 14, 2020 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .