Permissions

From TheLinuxVault

Jump to: navigation, search


Linux Basics
Permissions


Related How-to's:

Linux was built to be secure from the ground up and has inherited many things from its *NIX roots. One of the most visible of these is Linux's approach to permissions. To introduce we must explain, what is a permission? Because Linux is secure from the ground up, every file, every program, every device in your Linux system has a set of permissions associated with it detailing who owns this file, and what may be done to this file by various users. Permissions on a Linux system are set not on an individual basis but based on groups of users (logically named groups) Each file in Linux has 3 different sets of permissions, a set for its Owner, a set for all the users in the owners Group and the set of all Other users. Each group contains 3 different permissions: Read, Write and Execute. Each permission may be set individually or in bunches allowing useful security protocols to be enforced.

[edit] Finding and Reading Permissions

Permissions are not generally visible and you will often not even notice they exist until you encounter Linux's characteristic permission denied error. The ls command allows you to view the permission of the files in any directory in which you have the read permissions (permissions at work!). In order to view the permissions of a folder we use the command ls -l often alised to ll. Lets have a look at a sample output of the command ls -l to see what it looks like.

drwxr--r-- 2 root root 4.0K 2006-03-02 16:40 Mail

The permission column is the first column of this output. We can decipher what this gibberish means by breaking it up into logical groups.

d | rwx | r-- | r--

The initial d tells us that we are looking not at a file but at a directory. Then each group of 3 letters tells us a set of permissions in the order of Owner Group Other. In this case the owner can read write execute and everyone else can only read. This raises the question of what it means to be able to read or execute a folder. r is the permission that is required to see the listing of files in a folder. If you run ls in a folder which you do not have r in, you will get a permission denied error.

[edit] Changing Permissions

Now that we know how to check our files' permissions, we will learn how to change the permission of a file. The command that we need is chmod. chmod requires us to pass the changes that we want, not the new permissions. Suppose I want to allow the users in my group to read my mail (not generally a wise idea) the command I would run would be:

chmod g+r Mail

The middle argument meaning "add the permissions r to my group"

This article is a stub. You can help The Linux Vault by expanding it.
Personal tools