FILE PERMISSION

What is File Permission?

File permission is a way to provide restriction and access to a certain user(s) and/or group(s).

In this section, we will briefly discuss: chmod and chown.

 


CHMOD (Change mode)

Chmod is used to provide certain level of permission and access to a file or a group of files. The modes are either read, write, and/or execute.

1. Anybody can read, write, execute.
rwx rwx rwx
chmod 777 <filename>
chmod -R 777 <folder/directory>

2. Owner & Group can read, write, execute. Everyone else can read, execute.
rwx rwx r-x
chmod 775<filename>
chmod -R 775 <folder/directory>

3. Owner & Group can read, write, execute. Everyone else can read.
rwx rwx r–
chmod 774<filename>
chmod -R 774 <folder/directory>

4. Owner can read, write, execute. Everyone else can read, execute.
rwx r-x r-x
chmod 755<filename>
chmod -R 755 <folder/directory>

5. Owner can read, write, execute. No one else has any rights.
rwx — —
chmod 700<filename>
chmod -R 700 <folder/directory>

6. Everyone can read, write.
rw- rw- rw-
chmod 666<filename>
chmod -R 666 <folder/directory>

7. Owner & Group can read, write. Everyone else can read.
rw- rw- r–
chmod 664<filename>
chmod -R 664 <folder/directory>

8. Owner can read, write. Everyone else can read.
rw- r– r–
chmod 644<filename>
chmod -R 644 <folder/directory>

 


CHOWN (Change Ownership)

Chown is used to set a file(s) or folder(s) to a particular username and/or group.

 

It can be used in two ways:

Method 1:
chown <owner>.<group> <file>
chown -R <owner>.<group> <folder>

METHOD 2:
chown owner <file>
chgrp group <file>
chown -R <owner> <folder>
chgrp -R <group> <folder>

 

***image credits to: LinuxCommand.org
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s