<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://vrl.cs.brown.edu/wiki/index.php?action=history&amp;feed=atom&amp;title=Understanding_File_Permissions</id>
	<title>Understanding File Permissions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://vrl.cs.brown.edu/wiki/index.php?action=history&amp;feed=atom&amp;title=Understanding_File_Permissions"/>
	<link rel="alternate" type="text/html" href="http://vrl.cs.brown.edu/wiki/index.php?title=Understanding_File_Permissions&amp;action=history"/>
	<updated>2026-04-18T05:35:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://vrl.cs.brown.edu/wiki/index.php?title=Understanding_File_Permissions&amp;diff=4279&amp;oldid=prev</id>
		<title>Brad Berg: New page: On Linux, there are three basic permissions that may be modified for a file: &#039;&#039;&#039;r&#039;&#039;&#039;, &#039;&#039;&#039;w&#039;&#039;&#039;, and &#039;&#039;&#039;x&#039;&#039;&#039;, which stand for &#039;&#039;&#039;r&#039;&#039;&#039;ead, &#039;&#039;&#039;w&#039;&#039;&#039;rite, and e&#039;&#039;&#039;x&#039;&#039;&#039;ecute.  For a given file, t...</title>
		<link rel="alternate" type="text/html" href="http://vrl.cs.brown.edu/wiki/index.php?title=Understanding_File_Permissions&amp;diff=4279&amp;oldid=prev"/>
		<updated>2010-05-04T17:59:24Z</updated>

		<summary type="html">&lt;p&gt;New page: On Linux, there are three basic permissions that may be modified for a file: &amp;#039;&amp;#039;&amp;#039;r&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;w&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;#039;, which stand for &amp;#039;&amp;#039;&amp;#039;r&amp;#039;&amp;#039;&amp;#039;ead, &amp;#039;&amp;#039;&amp;#039;w&amp;#039;&amp;#039;&amp;#039;rite, and e&amp;#039;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;#039;ecute.  For a given file, t...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;On Linux, there are three basic permissions that may be modified for a file: &amp;#039;&amp;#039;&amp;#039;r&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;w&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;#039;, which stand for &amp;#039;&amp;#039;&amp;#039;r&amp;#039;&amp;#039;&amp;#039;ead, &amp;#039;&amp;#039;&amp;#039;w&amp;#039;&amp;#039;&amp;#039;rite, and e&amp;#039;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;#039;ecute.  For a given file, the permissions may be different for three different classes of users, &amp;#039;&amp;#039;&amp;#039;u&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;g&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;o&amp;#039;&amp;#039;&amp;#039;, which stand for the &amp;#039;&amp;#039;&amp;#039;u&amp;#039;&amp;#039;&amp;#039;ser who owns the file, other members of the owner&amp;#039;s &amp;#039;&amp;#039;&amp;#039;g&amp;#039;&amp;#039;&amp;#039;roup, and &amp;#039;&amp;#039;&amp;#039;o&amp;#039;&amp;#039;&amp;#039;ther users.  Therefore there are a total of nine permission bits on each file.  Each three-bit &amp;#039;&amp;#039;&amp;#039;rwx&amp;#039;&amp;#039;&amp;#039; code may be represented in binary as a number between 0 and 7:&lt;br /&gt;
&lt;br /&gt;
{| border=1 | align=center | cellpadding=3px&lt;br /&gt;
|-&lt;br /&gt;
! # !! r !! w !! x !! Permission&lt;br /&gt;
|-&lt;br /&gt;
! 0&lt;br /&gt;
| 0 || 0 || 0 || No access&lt;br /&gt;
|-&lt;br /&gt;
! 1&lt;br /&gt;
| 0 || 0 || 1 || Execute only&lt;br /&gt;
|-&lt;br /&gt;
! 2&lt;br /&gt;
| 0 || 1 || 0 || Write only&lt;br /&gt;
|-&lt;br /&gt;
! 3&lt;br /&gt;
| 0 || 1 || 1 || Write and execute&lt;br /&gt;
|-&lt;br /&gt;
! 4&lt;br /&gt;
| 1 || 0 || 0 || Read only&lt;br /&gt;
|-&lt;br /&gt;
! 5&lt;br /&gt;
| 1 || 0 || 1 || Read and execute&lt;br /&gt;
|-&lt;br /&gt;
! 6&lt;br /&gt;
| 1 || 1 || 0 || Read and write&lt;br /&gt;
|-&lt;br /&gt;
! 7&lt;br /&gt;
| 1 || 1 || 1 || Read, write, and execute&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The entire set of permissions for a file or directory may therefore be compactly represented by a three-digit octal number.  For example, &amp;lt;tt&amp;gt;754&amp;lt;/tt&amp;gt; means that the owner may read, write, and execute the file, other members of the owner&amp;#039;s group may read and execute it, and all others may only read.&lt;br /&gt;
&lt;br /&gt;
=== Default permissions for new files ===&lt;br /&gt;
&lt;br /&gt;
When a new file is created, it starts off having permissions &amp;lt;tt&amp;gt;666&amp;lt;/tt&amp;gt; (read and write allowed for all users).  For directories, the execute permission means that the user can access the directory, and so the initial permissions on a new directory are &amp;lt;tt&amp;gt;777&amp;lt;/tt&amp;gt; (read, write, and access allowed for all users).&lt;br /&gt;
&lt;br /&gt;
These initial permissions are modified by what&amp;#039;s called the &amp;quot;umask&amp;quot; or &amp;quot;file mode creation mask&amp;quot;.  This is a nine-bit binary mask that is XOR&amp;#039;d with the initial permissions.  By default, the umask is &amp;lt;tt&amp;gt;022&amp;lt;/tt&amp;gt;, and therefore a new file will come out with permissions &amp;lt;tt&amp;gt;644&amp;lt;/tt&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;&amp;lt;tt&amp;gt;666&amp;amp;nbsp;^&amp;amp;nbsp;022&amp;lt;/tt&amp;gt; (read and write for the owner, read only for all others).&lt;br /&gt;
&lt;br /&gt;
Every member of our research group is a member of the &amp;lt;tt&amp;gt;graphics&amp;lt;/tt&amp;gt; group on the CS department network.  In order to facilitate code sharing and collaboration, we need to make sure that read and write permissions are set not just for the owner of a file, but for all members of the &amp;lt;tt&amp;gt;graphics&amp;lt;/tt&amp;gt; group, too.  This is easily accopmlished by setting the umask to &amp;lt;tt&amp;gt;002&amp;lt;/tt&amp;gt; instead: &amp;lt;tt&amp;gt;666&amp;lt;/tt&amp;gt;&amp;amp;nbsp;^&amp;amp;nbsp;&amp;lt;tt&amp;gt;002&amp;amp;nbsp;=&amp;amp;nbsp;664&amp;lt;/tt&amp;gt; (read and write for the owner and members of the owner&amp;#039;s group, read only for all others).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;umask&amp;lt;/tt&amp;gt; command either views or sets the current value of the umask.  The config file &amp;lt;tt&amp;gt;~/.environment&amp;lt;/tt&amp;gt; is run every time you open a shell, and the default one created by the CS department for new users sets the umask to &amp;lt;tt&amp;gt;022&amp;lt;/tt&amp;gt;.  To set the umask to &amp;lt;tt&amp;gt;002&amp;lt;/tt&amp;gt; at the beginning of every shell session, just edit your &amp;lt;tt&amp;gt;~/.environment&amp;lt;/tt&amp;gt; file.  Look for the line&lt;br /&gt;
&amp;lt;pre width=&amp;quot;30%&amp;quot;&amp;gt;umask 022&amp;lt;/pre&amp;gt;&lt;br /&gt;
and change it to&lt;br /&gt;
&amp;lt;pre width=&amp;quot;30%&amp;quot;&amp;gt;umask 002&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To make your change take effect immediately, execute the following command in all your open shells:&lt;br /&gt;
&amp;lt;pre width=&amp;quot;30%&amp;quot;&amp;gt;source ~/.environment&amp;lt;/pre&amp;gt;&lt;br /&gt;
If that gives you an error, try the following instead:&lt;br /&gt;
&amp;lt;pre width=&amp;quot;30%&amp;quot;&amp;gt;. ~/.environment&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can check that it worked by running &amp;lt;tt&amp;gt;umask&amp;lt;/tt&amp;gt;; the result should be &amp;lt;tt&amp;gt;002&amp;lt;/tt&amp;gt;.  From now on, any files you create from the command line will be writeable by the group.&lt;br /&gt;
&lt;br /&gt;
=== Commands you should know for dealing with permissions ===&lt;br /&gt;
Type &amp;lt;code&amp;gt;man &amp;amp;lt;command&amp;amp;gt;&amp;lt;/code&amp;gt; at the command line to get information about any of the following:&lt;br /&gt;
* &amp;lt;tt&amp;gt;umask&amp;lt;/tt&amp;gt; --- view or set the umask&lt;br /&gt;
* &amp;lt;tt&amp;gt;chmod&amp;lt;/tt&amp;gt; --- change the permissions for a file or directory&lt;br /&gt;
* &amp;lt;tt&amp;gt;chown&amp;lt;/tt&amp;gt; --- change the owner of a file or directory (only allowed if you are the owner)&lt;/div&gt;</summary>
		<author><name>Brad Berg</name></author>
	</entry>
</feed>