Understand the Basics of Permissions


Before moving on to the chmod command, which allows you to change the permissions associated with a file or directory, let's review how Linux understands those permissions.

Note

Linux systems are beginning to use a more granular and powerful permission system known as Access Control Lists (ACLs). At this time, however, ACLs are still not widely used, so they're not covered here. For more info about ACLs, see "Access Control Lists" at Linux Magazine (www.linux-mag.com/2004-11/guru_01.html) and "An ACL GUI for Linux" at The Open Source Weblog (http://opensource.weblogsinc.com/2005/12/06/an-acl-gui-for-linux/).


Linux understands that three sets of users can work with a file or directory: the actual owner (also known as the file's user), a group, and everyone else on the system. Each of these sets is represented by a different letter, as shown in Table 7.1.

Table 7.1. Users and Their Abbreviations

User Group

Abbreviation

User (owner)

u

Group

g

Others

o


In the "List Permissions, Ownership, and More" section in Chapter 2, "The Basics," you learned about long permissions, which indicate what users can do with files and directories. In that section, you looked at three attributes: read, write, and execute, represented by r, w, and x, respectively. Additional possibilities are suid, sgid, and the sticky bit, represented by s (or S on some systems), s (or S), and t (or T). Keep in mind, however, that all of these can have different meanings depending on whether the item with the attribute is a file or a directory. Table 7.2 summarizes each attribute, its abbreviation, and what it means.

Table 7.2. Permission Letters and Their Meanings

File Attribute

Abbreviation

Meaning for File

Meaning for Directory

Readable

r

Can view.

Can list with ls.

Writable

w

Can edit.

Can delete, rename, or add files.

Executable

x

Can run as program.

Can access to read files and subdirectories or to run files.

suid

s

Any user can execute the file with owner's permissins.

Not applicable.

sgid

s

Any user can execute the file with group's permissions.

All newly created files in a directory belong to the group owning the directory.

Sticky bit

t

Tells OS that the file will be frequently executed, so it's constantly kept in swap space for fast access (only for older Unix systems; Linux ignores.)

User cannot delete or rename files, unless he is the file's or containing directory' owner.


Note

The root user can always do anything to any file or directory, so the previous table doesn't apply to root.


Each of these file attributes is covered in more detail in the following sections. Now that you understand the basics, let's look at using the chmod command to change the permissions of files and directories.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net