Linux File Permissions: the Tutorial

Linux File Permissions: the 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 by any masquerader.

Linux File Permissions: the Tutorial

As you might be aware of 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.

chmod command in Linux

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, as we’ve discussed:

  • 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]

Let’s look at an example:
We have a file called “systems.lst”. We need to change its owner to a user called xyz who is in the abc group:
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]

Here is an example:
There is a file called “” that we want to change to be owned by the abc group:
chgrp abc

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

We hope sharing this Linux Tutorial will indeed be useful to you, don’t forget to re share it.


 Comment Policy

Your words are your own, so be nice and helpful if you can. Please, only use your REAL NAME, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please. You can wrap code in [lang-name][/lang-name] tags.

Tell us what you're thinking...

If you want a picture to show with your comment, then get Gravatar!

CommentLuv badge