# Change File Ownership and Permissions

To change the owners of a file, you can use the following commands:

* `chown`
  * This changes the user who owns a particular file or directory.
* `chgrp`
  * This changes the group who owns a particular file or directory.

To change the permissions that the owners of a file have, you use the `chmod` command.

`chmod` takes two arguments: the permissions to give a file, and the file to change the permissions of. The permissions are represented as a 3-digit number, where each digit represents the permissions to give the user, group, or others, respectively.

Read, write, and execute permissions are represented by the following numbers:

* r - 4
* w - 2
* x - 1

If you want to give someone multiple permissions, you add the numeric representations of those permissions together. For example:

* Read, write, execute (rwx) permissions = (4 + 2 + 1) = 7
* Write, execute (\_wx) permissions = (2 + 1) = 3

So let's say you want to give a file the following permissions:

* The user that owns the file should be able to read, write, and execute the file. rwx = (4 + 2 + 1) = 7
* The group that owns the file should be able to read and execute the file. r\_x = (4 + 1) = 5
* Anyone else should have no permissions for the file. \_\_\_ = 0

The you'd run the following command:

```bash
chmod 750 arrayDat.txt
```

Remembering the syntax for this command can be quite cumbersome, so I recommend using a third-party website such as <https://quickref.me/chmod>.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://igb.mit.edu/mini-courses/introduction-to-unix/files/file-ownership/change-file-ownership-and-permissions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
