<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.tordeu.com &#187; sbin</title>
	<atom:link href="http://blog.tordeu.com/?feed=rss2&#038;tag=sbin" rel="self" type="application/rss+xml" />
	<link>http://blog.tordeu.com</link>
	<description>a blog about stuff</description>
	<lastBuildDate>Thu, 25 Apr 2013 07:03:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2</generator>
		<item>
		<title>Changing PATH to include /sbin or: How to fix &#8220;bash: ldconfig: command not found&#8221;</title>
		<link>http://blog.tordeu.com/?p=374</link>
		<comments>http://blog.tordeu.com/?p=374#comments</comments>
		<pubDate>Fri, 08 Jun 2012 00:23:51 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[PATH]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[sbin]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=374</guid>
		<description><![CDATA[It&#8217;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 <a href='http://blog.tordeu.com/?p=374'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p>It&#8217;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:</p>
<pre>bash: ldconfig: command not found</pre>
<p>You might encounter this error or something very similar, especially when you are using sudo instead of changing to root with su (<a title="How to enable sudo in Linux (here: Debian Squeeze)?" href="http://blog.tordeu.com/?p=31">see my article on how to enable sudo</a>).</p>
<p>&nbsp;</p>
<h2>Problem</h2>
<p>The problem is that programs like ldconfig are located in the  /sbin folder, but this folder is not added to the PATH variable.</p>
<p>If you don&#8217;t know what PATH is:</p>
<p>The path variable is essentially a list of folders. When you type a command in bash (the terminal/command line) like this:</p>
<pre>ldconfig</pre>
<p>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.</p>
<p>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.</p>
<p>&nbsp;</p>
<h2>Solution</h2>
<p>The solution is to add  &#8220;/sbin&#8221; to the PATH variable. This can be done by editing the file &#8220;/etc/profile&#8221;.</p>
<p>Type</p>
<pre>sudo nano /etc/profile</pre>
<p>or &#8211; if you are more comfortable with a GUI based text editor &#8211; you can also type</p>
<pre>sudo gedit /etc/profile</pre>
<p>&nbsp;</p>
<p>At the beginning of the file, you will see the following:</p>
<pre>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</pre>
<p>This sets the PATH variable for the root user and every other user. The first line that starts with &#8220;PATH=&#8230;&#8221; sets the PATH for the root user and the second line sets PATH for everybody else. So the code fragment basically translates to:</p>
<pre>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"</pre>
<p>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:</p>
<ul>
<li>
<pre>/usr/local/bin</pre>
</li>
<li>
<pre>/usr/bin</pre>
</li>
<li>
<pre>/bin</pre>
</li>
<li>
<pre>/usr/local/games</pre>
</li>
<li>
<pre>/usr/games</pre>
</li>
</ul>
<p>We want to add a few directories to that, namely:</p>
<ul>
<li>
<pre>/usr/local/sbin</pre>
</li>
<li>
<pre>/usr/sbin</pre>
</li>
<li>
<pre>/sbin</pre>
</li>
</ul>
<p>For ldconfig and a lot of other programs, adding &#8220;/sbin&#8221; would be enough, but I added the others as well, because I thought: &#8220;I don&#8217;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&#8221;</p>
<p>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):</p>
<pre>if user=root then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
otherwise
  PATH="<span style="color: #ff0000;">/usr/local/sbin:</span>/usr/local/bin:<span style="color: #ff0000;">/usr/sbin:</span>/usr/bin:<span style="color: #ff0000;">/sbin:</span>/bin:/usr/local/games:/usr/games"
fi</pre>
<p>Save the file; when using nano, just</p>
<ul>
<li>hit &#8220;Ctrl+X&#8221; to quit</li>
<li>then &#8220;Y&#8221; to confirm that you want to save the modified version</li>
<li>then hit the enter key to confirm the filename</li>
</ul>
<p>And finally: Log out and log back in.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=374</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
