Knowledge about changing permissions for a specific file is pretty important and can even save Your information from being lost.
So let's see what we can check and how.
1. Execute next command in Your terminal window:
$ ls -la
You should see same information as on screen below.
What do those letters form first column stand for?
- d = directory
- r = read access
- w = write access
- x = execute access
- - = no permissions at all
Column 3 indicates owner of a file and column four shows us an user's group which might has or not permissions to read/write/execute file.
So if we'll check first column again from left to write we'll see that:
- first symbol / several symbols - user's permissions
- second symbol (after dash) / symbols - group permissions
- third symbol / symbols - all other users permissions
Let's analyse example.txt file:
- user has read and write permissions
- group has read and write permissions
- other users have only read permission
2. If You want to change ownership of the file just execute:
$ sudo chown NEW_USER:NEW_GROUP example.txt
this command will update owner and group for this file.
3. If You want just update permissions for specific file then You need to execute:
$ sudo chmod 000 example.txt
this command deny all actions with this file for all users.
4. Let's explore octets in general:
- 0 - No read, no write, no execute - " - "
- 1 - No read, no write, execute - " -x "
- 2 - No read, write, no execute - " -w- "
- 3 - No read, write, execute - " -wx "
- 4 - Read, no write, no execute - " r- "
- 5 - Read, no write, execute - " r-x "
- 6 - Read, write, no execute - " rw- "
- 7 - Read, write, execute - " rwx "
5. So according to this table if we'll execute next command:
$ sudo chmod 432 example.txt
- owner will be able only to read file;
- group will be able to write and execute;
- all others will be able only to write.
6. If You want to apply same permission to folder and all its content You have to add one more flag to Your command:
$ sudo chmod -R 777 Documents
This is pretty much core knowledge which You have to have in order to change permissions for folder / file in OSX terminal.
So let's see what we can check and how.
1. Execute next command in Your terminal window:
$ ls -la
You should see same information as on screen below.
What do those letters form first column stand for?
- d = directory
- r = read access
- w = write access
- x = execute access
- - = no permissions at all
Column 3 indicates owner of a file and column four shows us an user's group which might has or not permissions to read/write/execute file.
So if we'll check first column again from left to write we'll see that:
- first symbol / several symbols - user's permissions
- second symbol (after dash) / symbols - group permissions
- third symbol / symbols - all other users permissions
Let's analyse example.txt file:
- user has read and write permissions
- group has read and write permissions
- other users have only read permission
2. If You want to change ownership of the file just execute:
$ sudo chown NEW_USER:NEW_GROUP example.txt
this command will update owner and group for this file.
3. If You want just update permissions for specific file then You need to execute:
$ sudo chmod 000 example.txt
this command deny all actions with this file for all users.
4. Let's explore octets in general:
- 0 - No read, no write, no execute - " - "
- 1 - No read, no write, execute - " -x "
- 2 - No read, write, no execute - " -w- "
- 3 - No read, write, execute - " -wx "
- 4 - Read, no write, no execute - " r- "
- 5 - Read, no write, execute - " r-x "
- 6 - Read, write, no execute - " rw- "
- 7 - Read, write, execute - " rwx "
5. So according to this table if we'll execute next command:
$ sudo chmod 432 example.txt
- owner will be able only to read file;
- group will be able to write and execute;
- all others will be able only to write.
6. If You want to apply same permission to folder and all its content You have to add one more flag to Your command:
$ sudo chmod -R 777 Documents
This is pretty much core knowledge which You have to have in order to change permissions for folder / file in OSX terminal.