Linux File Permissions – The Beginners Tutorial

Linux provides full control over file access which ultimately helps many people to use the system. Files and data are maintained leaving no risks of them being changed, viewed, modified or deleted.

The Three Types Of Users In Linux Who May Have Access To The Files:

  • User – An account created by the administrator of the system for a user to access that system. Accounts may also be created for machine processes, like the mail, FTP, or web server. Users have direct ownership over files and directories on the system.
  • Group – Provides the ability to give access to sets of users. Groups have their own permissions over each file or directory.
  • World – Anyone else that may attempt to access a file on the machine.

Three Ways In Which These Types Of People Can Access The File:

  • Read – Opening a file and looking at its contents.
  • Write – Overwrite, append, or delete a file. In directories, this may include creation of files.
  • Execute – The ability to “run” a program (or script).

The “most restrictive access” policy is used for granting any kind of permissions as and when needed. No one has access to anything for no reason.

Managing Permissions:

“chmod” (change mode) is a command for managing permissions.

Basic syntax for this command is:

chmod [who][how to change][permissions to modify] [file or directory name]

The “who” can be:

  • u – user or account that owns the file
  • g – group that owns the file
  • o – others, or “world”, anyone else who may access the file
  • a – all of the above

The “how to change” can be:

  • = (equals) – set the permissions to exactly what immediately follows
  • + (add) – add the permission that immediately follows, leave others as-is
  • (minus) – subtract the permission that immediately follows, leave others as they are

The “permissions to modify” can be:

  • r – read
  • w – write
  • x – execute

Changing Owners And Groups:

1. chown

Two popular commands exist that can be used for modifying the owning user and group of a file. The first is “chown” (change owner).

The syntax for this is:

chown [user]:[group] [file or directory]

Example: We have a file called “systems.lst” and we need to change its owner to a user called xyz who is in the abc group. Then the command is chown xyz:abc systems.lst

2. chgrp

Anyone intending to change the group, can use another command called “chgrp” (change group.

The syntax for this command is:

chgrp [group name] [file or directory name]

Example: There is a file called “run.sh” that we want to change to be owned by the abc group. Then the command is chgrp abc run.sh.

Other Linux Commands:

  • useradd – add a system user
  • userdel – remove a system user
  • usermod – modify an existing system user. This can be used to perform several operations on a user’s account.
  • groupadd – add a group to the system
  • groupdel – remove a group from the system
  • groupmod – modify a group

Source : techlila

Related posts

How to Improve Your Cyber Resilience by Strengthening User Privileges

The Dark Side of Viral Content: How Negative Reviews Can Snowball

Testing Gaming Monetization: Walking the Line Between Profit and Player Experience