0
4.8kviews
Explain Linux file access permissions

Mumbai University > Information Technology > Sem 5 > Open Source Technology

Marks: 5M

Year: Dec 2015

1 Answer
1
161views

Linux file access permissions are used to control who is able to read, write and execute a certain file. This is an important consideration due to the multi-user nature of Linux systems and as a security mechanism to protect the critical system files both from the individual user and from any malicious software or viruses. Access permissions are implemented at a file level with the appropriate permission set based on the file owner, the group owner of the file and world wide access. In Linux, directories are also files and therefore the file permissions apply on a directory level as well, although some permission are applied differently depending upon whether the file is a regular file or directory. As devices are also represented as files then the same permissions commands can be applied to access to certain resources or external devices.

Basic File Permissions

  1. Permission Groups

    Each file and directory has three user based permission groups:

  • Owner - The Owner permissions apply only the owner of the file or directory, they will not impact the actions of other users.
    • group - The Group permissions apply only to the group that has been assigned to the file or directory, they will not effect the actions of other users.
  • all users - The All Users permissions apply to all other users on the system, this is the permission group that you want to watch the most.
  • Permission Types

    Each file or directory has three basic permission types:

  • read - The Read permission refers to a user's capability to read the contents of the file.

  • write - The Write permissions refer to a user's capability to write or modify a file or directory.
  • Execute - The Execute permission affects a user's capability to execute a file or view the contents of a directory.
  • Viewing the Permissions

    You can view the permissions by checking the file or directory permissions in your favorite GUI File Manager (which I will not cover here) or by reviewing the output of the \"ls -l\" command while in the terminal and while working in the directory which contains the file or folder.

    The permission in the command line is displayed as: _rwxrwxrwx 1 owner:group

  • User rights/Permissions
    • The first character that I marked with an underscore is the special permission flag that can vary.
    • The following set of three characters (rwx) is for the owner permissions.
    • The second set of three characters (rwx) is for the Group permissions.
    • The third set of three characters (rwx) is for the All Users permissions.
  • Following that grouping since the integer/number displays the number of hardlinks to the file.
  • The last piece is the Owner and Group assignment formatted as Owner:Group.
  1. Modifying the Permissions

    When in the command line, the permissions are edited by using the command chmod. You can assign the permissions explicitly or by using a binary reference as described below.

  2. Explicitly Defining Permissions

    To explicitly define permissions we need to reference the Permission Group and Permission Types.

    The Permission Groups used are:

  3. u - Owner
  4. g - Group
  5. o or a - All Users

    The potential Assignment Operators are + (plus) and - (minus); these are used to tell the system whether to add or remove the specific permissions. The Permission Types that are used are:

  6. r - Read
  7. w - Write
  8. x - Execute

    So for an example, let’s say we have a file named file1 that currently has the permissions set to_rw_rw_rw, which means that the owner, group and all users have read and write permission. Now we want to remove the read and write permissions from the all users group.

    To make this modification we would invoke the command: chmod a-rw file1

    to add the permissions, we would invoke the command: chmod a+rw file1

Please log in to add an answer.