Working with Permissions

Under Linux (and UNIX), everything in the file system, including directories and devices, is a file. And every file on your system has an accompanying set of permissions based on ownership. These permissions form the basis for security under Linux, and designate each file's read, write, and execute permission for you, members of your group, and all others on the system.

You can examine the default permissions for a file you create by using the umask command, or as a practical example, by using the touch command and then the is command's long-format listing like this:

-rw-r—r— 1 andrew andrew 0 2006-05-31 20:16 file

In this example, the touch command is used to quickly create a file. The ls command then reports on the file, displaying information (from left to right) in the first field of output (such as -rw-rw-r--previously)

• The first character of the field is the type of file created Common indicators of the type of file are a leading letter in the output. A blank (which is represented by a dash in the preceding example) designates a plain file, d designates a directory, c designates a character device (such as /dev/ttys0), and b is used for a block device (such as /dev/hda).

• Permissions Read, write, and execute permissions for the owner, group, and all others on the system. (You learn more about these permissions later in this section.)

• Number of links to the file The number one (1) designates that there is only one file, whereas any other number indicates that there might be one or more hard-linked files. Links are created with the ln command. A hard-linked file is an exact copy of the file, but it might be located elsewhere on the system. Symbolic links of directories can also be created, but only the root operator can create a hard link of a directory.

• The owner The account that created or owns the file; you can change this designation by using the chown command.

• The group The group of users allowed to access the file; you can change this designation by using the chgrp command.

• File size and creation/modification date The last two elements indicate the size of the file in bytes and the date the file was created or last modified.

Was this article helpful?

0 0

Post a comment