Day 6 Task: File Permissions and Access Control Lists.

Day 6 Task: File Permissions and Access Control Lists.

The concept of Linux File permission and ownership is important in Linux. Here, we will be working on Linux permissions and ownership and will do tasks on both of them. Let us start with the Permissions.

Check File Permissions in Linux

There, you’ll see that the permission for each file differs according to three categories:

  • Owner (the user who created the file/directory)

  • Group (to which the owner belongs to)

  • Others (all other users)

  • Check Permissions in Command-Line with Ls Command= ls –l [filename]

It shows the permission settings, grouped in a string of characters (-, r, w, x) classified into four sections:

  1. File type. There are three possibilities for the type. It can either be a regular file (), a directory (d) or a link (i).

  2. File permission of the user (owner).

  3. File permission of the owner’s group.

  4. File permission of other users.

The characters r, w, and x stand for read, write, and execute.

Chmod Command: -

As all Linux users, you will at some point need to modify the permission settings of a file/directory. The command that executes such tasks is the chmod command.

The basic syntax is:

chmod [permission] [file_name]

There are two ways to define permission:

  1. using symbols (alphanumerical characters)

  2. using the octal notation method

Define File Permission with Symbolic Mode

  • To specify permission settings using alphanumerical characters, you’ll need to define accessibility for the user/owner (u), group (g), and others (o).

  • Type the initial letter for each class, followed by the equal sign (=) and the first letter of the read (r), write (w) and/or execute (x) privileges.

  • To set a file, so it is public for reading, writing, and executing, the command is:

chmod u=rwx, g=rwx, o=rwx [file_name]

Define File Permission in Octal/Numeric Mode

specify permission is by using the octal/numeric format

Instead of letters, the octal format represents privileges with numbers:

  • r(ead) has the value of 4

  • w(rite) has the value of 2

  • (e)x(ecute) has the value of 1

  • no permission has the value of 0

The privileges are summed up and depicted by one number. Therefore, the possibilities are:

  • 7 – for read, write, and execute permission.

  • 6 – for read and write privileges.

  • 5 – for read and execute privileges.

  • 4 – for read privileges.