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 found

You 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).



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:


then 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.



The solution is to add  “/sbin” to the PATH variable. This can be done by editing the file “/etc/profile”.


sudo nano /etc/profile

or – 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

This 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

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

We want to add a few directories to that, namely:

  • /usr/local/sbin
  • /usr/sbin
  • /sbin

For ldconfig and a lot of other programs, adding “/sbin” would be enough, but I added the others as well, because I thought: “I don’t wanna come back two more times, just because I might realize later that I should have added them as well in the first place”

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

Save 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

And finally: Log out and log back in.

  7 Responses to “Changing PATH to include /sbin or: How to fix “bash: ldconfig: command not found””

  1. Very useful, thanks!

  2. I faced the same issue today, and apparently this happens because I did not update the sudoers file while doing a dist upgrade. It got fixed by adding
    Defaults secure_path=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
    under the Defaults line.

    Got the tip from

  3. Thanks for your instruction. I encountered the same problem today. However, when I opened the file, I didn’t see the same content as you described above. Instead, the file reads as follows:

    # System-wide .profile for sh(1)

    if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`

    if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc

    I looked up online and it seem that this is how default /etc/profile looks like…
    Should I still add the lines that you recommended regardless?

    Thanks again!

    • You probably just have a different linux distribution than I do (I did that on Debian Wheezy). That isn’t a problem though.

      You can do one of two things:

      1. Look at /etc/bashrc, PATH may be defined there

      2. You can add the following two lines at the end of /etc/profile:

      export PATH

      This adds the three sbin directories to an already existing PATH variable.

      • Thank you very much! I just realized I missed the very first sentence in your original post: your system was a Debian Wheezy system. Mine is a mac and there is no ldconfig command for mac after all. Now I felt silly that I asked that question. But I’m not the one to blame. I was reading an instruction for installing imageMagick on unix system and was told to use ldconfig.
        BTW, thanks for your reply. I now know how to modify the path variable :)

  4. Do we need special priveleges for editing the PATH environment variable?
    When I tried I got the error : (user) is not allowed to execute ‘/usr/bin/nano /etc/profile’ as root on (localhost)

    *user and localhost are place holders

Leave a Reply to tordeu Cancel reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>