It’s been a while, but in the oh so distant past I stumbled upon the following error on my then fairly new Debian Wheezy system:
bash: ldconfig: command not foundYou might encounter this error or something very similar, especially when you are using sudo instead of changing to root with su (see my article on how to enable sudo).
Problem
The problem is that programs like ldconfig are located in the /sbin folder, but this folder is not added to the PATH variable.If you don’t know what PATH is:
The path variable is essentially a list of folders. When you type a command in bash (the terminal/command line) like this:
ldconfigthen bash will go through all the folders listed in the PATH variable and see if a program with that name is in that folder. If it finds that program, it will execute it.
The problem here is that PATH (the list of directories where bash will look for the program) does not contain the folder /sbin. But because the program is in this folder and bash does not look there, bash will not find the program and instead annoy you with an error.
Solution
The solution is to add “/sbin” to the PATH variable. This can be done by editing the file “/etc/profile”.Type
sudo nano /etc/profileor – if you are more comfortable with a GUI based text editor – you can also type
sudo gedit /etc/profile
At the beginning of the file, you will see the following:
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" fiThis sets the PATH variable for the root user and every other user. The first line that starts with “PATH=…” sets the PATH for the root user and the second line sets PATH for everybody else. So the code fragment basically translates to:
if user=root then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" otherwise PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"The second line is what we have to care right now. The directories in the list are separated by a colon, so the list contains the following directories:
-
/usr/local/bin
-
/usr/bin
-
/bin
-
/usr/local/games
-
/usr/games
-
/usr/local/sbin
-
/usr/sbin
-
/sbin
You could add the directories anywhere in the list, but I like to add them in the same order they appear in the PATH variable for the root user, so I will change the beginning of the file to this (remember to separate the directories with a colon):
if user=root then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" otherwise PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games" fiSave the file; when using nano, just
- hit “Ctrl+X” to quit
- then “Y” to confirm that you want to save the modified version
- then hit the enter key to confirm the filename
from http://blog.tordeu.com/?p=374