Changing file and folder access permissions with chmod and chown

To change a folder or file's permission settings, you use the 'chmod' command. The arguments to this command are the permission setting -represented by a number- and the file or folder you want to change the permissions on.


Lets say for example, you wanted to change the permissions on all the files on your data partition that we just set up on the last page, you would tell it to change the permissions on the folder that contains the files, and you would tell it to execute the command RECURSIVELY with the '-R' switch. So this will affect the folder that contains all your files, then all the files inside that folder, then all the folders inside that folder, and then all the files in those folders, until it runs out of folders to go into and files to change. Here's an example command to change the permissions on all the contents:

chmod 777 /A -R

The first '7' tells chmod that the file's owner is allowed to read, write, and execute the files specified by the path argument. The second '7' is for the Group permissions, in this case 'group' is the group that the OWNER of the of the files belongs to. The third '7' is for everyone else. Play with the permissions below by clicking on them to get a better understanding of how they work:




OWNERGROUPOTHERS
Read: 4 Read: 4 Read: 4
Write: 2 Write: 2 Write: 2
Exec: 1 Exec: 1 Exec: 1
0 0 0


Changing file ownership with chown

If you right click on a file or folder, and go to 'properties', and select the 'permissions' tab, you will see many settings, but the ones i want you to notice are the 'Owner', 'Group', and 'Others' settings. The owner and group of the file can be changed if need be, but you'll never have to change 'others' as it refers to 'everyone' or 'no one' or 'anonymous'. In order to change a file or folder's OWNER and GROUP settings, type in the command below. You can also change these settings Recursively with the '-R' switch that i went into detail about earlier in the above section about permissions.

chown Alex:AlexGroupName /A -R

The first part -'Alex'- specifies the new Owner of the file. The second part -'AlexGroupName'- specifies the group who has group-permissions to the file, remember, the group permissions don't have to be the same as the owner permissions, as you'll notice in the permissions table above. The next part is the path of course, and we tell it to operate recursively under that path with the '-R' switch. Also note that your file/folder's owner does not have to be a member of that file's group.

Article Tools and Options

Direct Link to this Page: http://linuxintro.com/?a=WCMS_Page_Display&id=769908929029

Rate the Importance or Relevance of is this Article?
0 1 2 3 4 5 6 7 8 9

Current Rating: 9.0   Page Views: 4786

Share/Bookmark


Subscribe to this Article (notified of new pages)

Flag this ArticleEdit this ArticleEdit this Page

Article Contributors (ordered by user's LAST edit time):

Vector [!]

User Comments

Leave a Comment for this page






Web services by Ionisis: Best SEO Company for Google | Information Systems | Web Development