<?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>dan.forys.co.uk &#187; permissions</title>
	<atom:link href="http://dan.forys.co.uk/tag/permissions/feed/" rel="self" type="application/rss+xml" />
	<link>http://dan.forys.co.uk</link>
	<description>Dan is a web developer in London. He is interested in all things Internet, Linux and Mac.</description>
	<lastBuildDate>Fri, 22 Jan 2010 14:25:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Understanding Linux file permissions</title>
		<link>http://dan.forys.co.uk/understanding-linux-file-permissions/</link>
		<comments>http://dan.forys.co.uk/understanding-linux-file-permissions/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 09:37:20 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[permissions]]></category>

		<guid isPermaLink="false">http://www.danforys.com/?p=29</guid>
		<description><![CDATA[They&#8217;re funny things Linux file permissions &#8211; the moment you think you understand them, you discover some subtle piece of functionality that means you were wrong all-along&#8230; In this three-part article, I give a brief introduction to file and directory permissions, as well as some of the common gotchas. This part shows you how to [...]]]></description>
			<content:encoded><![CDATA[<p>They&#8217;re funny things Linux file permissions &#8211; the moment you think you understand them, you discover some subtle piece of functionality that means you were wrong all-along&#8230;</p>
<p>In this three-part article, I give a brief introduction to file and directory permissions, as well as some of the common gotchas. This part shows you how to interpret permissions on the command line and explains what they mean.</p>
<p><span id="more-29"></span></p>
<p>One of the best ways to get a feel for the permissions, is using the shell. So, if you launch a shell session and type the following: (the &#8220;-l&#8221; means the long-listing format)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span></pre></div></div>

<p>You&#8217;ll see a listing of all the files in your home folder, something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drwxr-xr-x  <span style="color: #000000;">2</span> dan <span style="color: #c20cb9; font-weight: bold;">users</span>    <span style="color: #000000;">4096</span> <span style="color: #000000;">2007</span>-<span style="color: #000000;">12</span>-<span style="color: #000000;">13</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">34</span> bin
drwx------  <span style="color: #000000;">5</span> dan <span style="color: #c20cb9; font-weight: bold;">users</span>    <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-07-<span style="color: #000000;">25</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">30</span> Desktop
drwx------ <span style="color: #000000;">15</span> dan <span style="color: #c20cb9; font-weight: bold;">users</span>    <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-07-<span style="color: #000000;">18</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">49</span> Documents
drwxr-xr-x  <span style="color: #000000;">2</span> dan <span style="color: #c20cb9; font-weight: bold;">users</span>    <span style="color: #000000;">4096</span> <span style="color: #000000;">2007</span>-<span style="color: #000000;">12</span>-<span style="color: #000000;">13</span> <span style="color: #000000;">11</span>:08 public_html
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> dan <span style="color: #c20cb9; font-weight: bold;">users</span>   <span style="color: #000000;">12094</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">10</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">22</span> readme.txt</pre></div></div>

<p>Of particular interest to us, is the first set of characters which represent the permissions: (numbered below, for reference)</p>
<pre>drwxr-xr-x
12345678910</pre>
<p>From left to right, the permissions are grouped into four parts:</p>
<ul>
<li><em>Character 1:</em> Indicates a directory (d), link (l) or normal file (-)</li>
<li><em>Characters 2-4:</em> The read (r), write (w) and execute (x) permissions for the file <em>owner</em> (&#8220;dan&#8221; in the example above)</li>
<li><em>Characters 5-7:</em> The read (r), write (w) and execute (x) permissions for the file <em>group</em> (&#8220;users&#8221; in the example above)</li>
<li><em>Characters 8-10:</em> The read (r), write (w) and execute (x) permissions for <em>everyone else</em> aka <em>others</em></li>
</ul>
<p>What these permissions mean, depends on what kind of file it is.<br />
For <strong>directories</strong>:</p>
<ul>
<li><em>Read (r)</em>: Users can view a listing of the directory contents (i.e. read its contents)</li>
<li><em>Write (w)</em>: Users can create / delete files in this directory (i.e. write to the directory&#8217;s contents).</li>
<li><em>Execute (x)</em>: Users can enter this directory using a &#8220;cd&#8221; command</li>
</ul>
<p>Note: If users have write access to a directory &#8211; they can delete its files <em>even if they are not the owner and/or do not have write permission to the individual file</em>. Watch out for this one, it has caught us out in the past!</p>
<p>For <strong>files</strong>:</p>
<ul>
<li><em>Read (r)</em>: Users can view the files&#8217; contents</li>
<li><em>Write (w)</em>: Users can modify the files&#8217; contents</li>
<li><em>Execute (x)</em>: Allows execution of the file as a program</li>
</ul>
<p>You should also be aware that Linux <em>only checks the most appropriate permissions</em> when deciding whether to grant access. For example, if you are the file owner, only the owner permission is checked (not the &#8220;group&#8221;, or &#8220;other&#8221; permissions). This means, if the permissions are &#8220;&#8212;-r&#8211;r&#8211;&#8221;, you won&#8217;t be able to read the file if you are the owner &#8211; whereas members of the file group and &#8220;others&#8221; will be able to read it.</p>
<p>That&#8217;s it for now! In the upcoming part two, I will detail how to set permissions, using the Linux command line. Part three will show you some of the more advanced permissions. Watch this space!</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.forys.co.uk/understanding-linux-file-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.124 seconds -->
