<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>sudo Sergeant 06: File Permissions</title><link>https://community.element14.com/challenges-projects/element14-presents/sudosergeant/w/documents/3153/sudo-sergeant-06-file-permissions</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>sudo Sergeant 06: File Permissions</title><link>https://community.element14.com/challenges-projects/element14-presents/sudosergeant/w/documents/3153/sudo-sergeant-06-file-permissions</link><pubDate>Fri, 18 Jan 2019 16:11:28 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f385961a-358f-4f11-b18a-e3e2eff236a0</guid><dc:creator>tariq.ahmad</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/sudosergeant/w/documents/3153/sudo-sergeant-06-file-permissions#comments</comments><description>Current Revision posted to Documents by tariq.ahmad on 1/18/2019 4:11:28 PM&lt;br /&gt;
&lt;table cellpadding="0" cellspacing="0" style="padding:0px;margin:0px;background-color:#c4e3ed;width:100%;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td rowspan="3" style="vertical-align:bottom;"&gt;&lt;a href="/e14/assets/legacy/2017/FelixExcLeft1.png"&gt;&lt;img alt="image" class="nolightbox" src="/e14/assets/legacy/2017/FelixExcLeft1.png"  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td rowspan="3" style="vertical-align:top;padding:8px 13px 13px 8px;"&gt;&lt;p style="margin:0;font-size:18px;font-weight:bold;padding-bottom:6px;"&gt;&lt;a class="jivecontainerTT-hover-container jive-link-community-small" href="/challengesprojects/element14-presents/benheck/"&gt;element14&amp;#39;s The Ben Heck Show&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding-bottom:6px;line-height:18px;"&gt;&lt;strong&gt;Join the Ben Heck team every week for amazing hacks!&lt;/strong&gt; Watch them build and mod community-inspired projects using electronics!&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="/challengesprojects/element14-presents/benheck/"&gt;Back to The Ben Heck Show homepage &lt;img loading="lazy" alt="image" src="/e14/assets/legacy/gen/LinkArrow.gif"  /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="padding:13px 10px 13px 13px;background-color:#004156;vertical-align:middle;" width="30%"&gt;&lt;a class="" href="https://www.element14.com/community/community/experts/benheck/sudosergeant?ICID=SS-episodedoc-topban"&gt;&lt;span style="color:#ffffff;text-decoration:none;"&gt;sudo Sergeant&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="padding:13px 10px 13px 13px;background-color:#005973;vertical-align:middle;"&gt;&lt;a class="jivecontainerTT-hover-container jive-link-community-small" href="/challengesprojects/element14-presents/benheck/ben-heck-exclusive/"&gt;&lt;span style="color:#ffffff;text-decoration:none;"&gt;Featured Bonus Content&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="padding:13px 10px 13px 13px;background-color:#006f91;vertical-align:middle;"&gt;&lt;a class="jive-link-wiki-small" href="/challenges-projects/element14-presents/benheck/ben-heck-exclusive/w/documents/9678/the-ben-heck-show-episode-archive"&gt;&lt;span style="color:#ffffff;text-decoration:none;"&gt;See All Episodes&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="width:80%;display:block;margin:0 auto;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="padding-bottom:12px;"&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=p7GZiwhEw9Q"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p style="margin:0;border:1px solid #b8d7e5;background-color:#e9f6fc;padding:8px;max-width:634px;"&gt;Felix discusses how file permissions work with Linux. He covers what they mean, what they’re for, and how to set them. You’ll learn to use command line to create a file and decipher user, group, and others rights. You can then add or remove permissions by CHMOD or by permission bits in octal notation.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;File permissions are the most basic form of security control on a Linux based operating system. They are implemented in a manner which can be configured to grant or deny access to files. The permissions can be modified by either the one who owns the file, or the super user.&amp;nbsp; The instruction to modify the permissions can take numeric arguments or symbolic arguments.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Felix uses a command line example to show you how to see the permissions of a file: Typing “ls” shows you the root directory structure.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~ $ ls&lt;/p&gt;&lt;p style="margin:0;"&gt;Desktop&amp;nbsp;&amp;nbsp; Documents&amp;nbsp;&amp;nbsp; Downloads Music&amp;nbsp;&amp;nbsp; Pictures&amp;nbsp; Public&amp;nbsp; Templates test&amp;nbsp; Videos&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/578x217/__key/communityserver-wikis-components-files/00-00-00-03-27/8737.contentimage_5F00_107996.gif"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/03/27/8737.contentimage_107996.gif-578x217.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=zbFhUMMvY85bcrouX8dTgYabybHs0XgxKFJFveL5T1k%3D&amp;amp;se=2026-04-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=DpWhtqRXLzL53PE1dwO/Hg==" style="max-height: 217px;max-width: 578px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;He wants to go the test directory so he types the command cd test. Typing ls again shows that this directory has two directories that were previously mounted.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~ $ cd test&lt;/p&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~ $ ls&lt;/p&gt;&lt;p style="margin:0;"&gt;mount0&amp;nbsp; mount 1&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Next he creates a files using command line using the touch command followed by the file he is creating and uses the ls command to verify the file was created:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $&amp;nbsp; touch testfile.text&lt;/p&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls&lt;/p&gt;&lt;p style="margin:0;"&gt;mount0 mount1 testfile.txt&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;To find the file permissions of this newly created file he types in ls -l:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls -l&lt;/p&gt;&lt;p style="margin:0;"&gt;total 8&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount0&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount1&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;- rw-r-- r-- 1&amp;nbsp; sergeant sergeant&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Aug 30 09:46 testfile.txt &lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;For testfile.txt the information to left of the number 1 are the file permissions. The first bit in the file permissions is the file type, the next 3 are the permissions of the owner,&amp;nbsp; the following three bits are the permissions of the group, and the last three are the permissions of anybody who is either not in the group or not the owner.&amp;nbsp; The last bit is a single character that specifies alternate access methods.&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/569x243/__key/communityserver-wikis-components-files/00-00-00-03-27/3060.contentimage_5F00_107997.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/03/27/3060.contentimage_107997.png-569x243.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=Kl6fvpO0laVZIU9eqJdqBVhO8eKQtWhmX6r9933dhZs%3D&amp;amp;se=2026-04-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=4TMN11fd+NQb5Vh2h3itcQ==" style="max-height: 243px;max-width: 569px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;For instance, if you see &amp;quot;drwxr&amp;quot; it means that the file type is director, the r means that the owner can read the directory, the w means the owner can write to the directory,&amp;nbsp; and x means the owner can execute the directory (since it&amp;#39;s a directory it doesn&amp;#39;t really get executed). The next 3 bits are the group rights. For testfile.txt, &amp;quot;r--&amp;quot; means that the group can read this but cannot write or execute.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;There are two ways to modify the file permissions.&amp;nbsp; They can either be done through numeric method or via a character method. With the character method, you would change the file permissions by sending the instruction chmod (change modify).&amp;nbsp; Felix suggests expanding the help anytime you have an instruction. After, using the&amp;nbsp; command &amp;quot;--help&amp;quot; Felix decides to give execution permissions to the user for the file by typing in the following command:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;In this example, read and write are turned off execute is turned on:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ chmod u=+x testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls -l&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;total 8&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount0&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount1&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;---xr-- r-- 1&amp;nbsp; sergeant sergeant&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Aug 30 09:46 testfile.txt &lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;In this example, read and write are added along with execute:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ chmod u=+rwx testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls -l&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;total 8&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount0&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount1&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;-rwxr-- r-- 1&amp;nbsp; sergeant sergeant&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Aug 30 09:46 testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;To give those same permissions to the group simply use the following command:&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/629x355/__key/communityserver-wikis-components-files/00-00-00-03-27/8750.contentimage_5F00_107998.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/03/27/8750.contentimage_107998.png-620x350.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=BhGvbqpq461XCI8OQ7twZl606zWg5ly0u3UG%2FTC6ca4%3D&amp;amp;se=2026-04-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=5jiqGXJdGOO0/4vxIh/G0Q==" style="max-height: 350px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ chmod g=+rwx testfile.txt&lt;/p&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls -l&lt;/p&gt;&lt;p style="margin:0;"&gt;total 8&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount0&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount1&lt;/p&gt;&lt;p style="margin:0;"&gt;-rwxrwxr-- 1&amp;nbsp; sergeant sergeant&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Aug 30 09:46 testfile.txt&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;To give those permissions to others you would use the following command:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ chmod o=+rwx testfile.txt&lt;/p&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls -l&lt;/p&gt;&lt;p style="margin:0;"&gt;total 8&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount0&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount1&lt;/p&gt;&lt;p style="margin:0;"&gt;-rwxrwxrwx 1&amp;nbsp; sergeant sergeant&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Aug 30 09:46 testfile.txt&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;To take away group permissions you would use the minus sign instead of the plus sign:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ chmod g=-rwx testfile.txt&lt;/p&gt;&lt;p style="margin:0;"&gt;sergeant@raspberrypi: ~/test&amp;nbsp; $ ls -l&lt;/p&gt;&lt;p style="margin:0;"&gt;total 8&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount0&lt;/p&gt;&lt;p style="margin:0;"&gt;drwxr-xr-x 2 sergeant sergeant 4096 Aug 25 13:40 mount1&lt;/p&gt;&lt;p style="margin:0;"&gt;-rwx---rwx 1&amp;nbsp; sergeant sergeant&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Aug 30 09:46 testfile.txt&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;This is covers adding and removing permissions using the character method.&amp;nbsp; To change permissions via the numeric method you can head over to&amp;nbsp; &lt;a class="jive-link-external-small" href="http://permissions-calculator.org/" rel="nofollow ugc noopener" target="_blank" title="http://permissions-calculator.org/"&gt;Unix Permissions and Lookup&lt;/a&gt; . Select your permissions bits. We&amp;#39;re focusing on user, group, and others.If you want to have read write execute for user group and others you would select those permissions on the page.&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/632x386/__key/communityserver-wikis-components-files/00-00-00-03-27/1212.contentimage_5F00_107999.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/03/27/1212.contentimage_107999.png-620x379.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=%2FZKRlaurHKn0WzggDKvPgO3pcsuayFrsH8d4u6Ddp8g%3D&amp;amp;se=2026-04-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=MmxbHlDug2u8xrDBbf5tJg==" style="max-height: 379px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test $ chmod 777 testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test $ ls -l testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;-rwxrwxrwx 1 sergeant sergeant 0 Aug 30 9:46 testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;Trying again with a different numeric value changes the file permissions:&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test $ chmod 700 testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;sergeant@raspberrypi: ~/test $ ls -l testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span style="background-color:#f6f6f6;"&gt;-rwx------ 1 sergeant sergeant 0 Aug 30 9:46 testfile.txt&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: numeric method, sudo sergeant, octal notation, file permissions, rpibeginner, character method, chmod, rpiexpert, command line, permission bits, sudosergeant, linux&lt;/div&gt;
</description></item></channel></rss>