quarta-feira, 28 de dezembro de 2011

Linux Files and File Permission

Linux files are setup so access to them is controlled. There are three types of access:
  1. read
  2. write
  3. execute
Each file belongs to a specific user and group. Access to the files is controlled by user, group, and what is called other. The term, other, is used to refer to someone who is not the user (owner) of the file, nor is the person a member of the group the file belongs to. When talking about setting permissions for "other" users to use, it is commonly referred to as setting the world execute, read, or write bit since anyone in the world will be able to perform the operation if the permission is set in the other category.

File names and permission characters

File names can be up to 256 characters long with "-", "_", and "." characters along with letters and numbers.
When a long file listing is done, there are 10 characters that are shown on the left that indicate type and permissions of the file. File permissions are shown according to the following syntax example: drwerwerwe
There are a total of 10 characters in this example, as in all Linux files. The first character indicates the type of file, and the next three indicate read, write, and execute permission for each of the three user types, user, group and other. Since there are three types of permission for three users, there are a total of nine permission bits. The table below shows the syntax:
12345678910
FileUser PermissionsGroup PermissionsOther Permissions
TypeReadWriteExecuteReadWriteExecuteReadWriteExecute
drwerwerwe
  • Character 1 is the type of file: - is ordinary, d is directory, l is link.
  • Characters 2-4 show owner permissions. Character 2 indicates read permission, character 3 indicates write permission, and character 4 indicates execute permission.
  • Characters 5-7 show group permissions. Character 5=read, 6=write, 7=execute
  • Characters 8-10 show permissions for all other users. Character 8=read, 9=write, 10=execute
There are 5 possible characters in the permission fields. They are:
  • r = read - This is only found in the read field.
  • w = write - This is only found in the write field.
  • x = execute - This is only found in the execute field.
  • s = setuid - This is only found in the execute field.
  • If there is a "-" in a particular location, there is no permission. This may be found in any field whether read, write, or execute field.

Examples

Type "ls -l" and a listing like the following is displayed:
total 10





drwxrwxrwx4georgeteam1122 Dec 12 18:02Projects
-rw-rw-rw-1george team11873Aug 23 08:34 test
-rw-rw-rw-1georgeteam11234 Sep 12 11:13 datafile
Which means the following:
Type and # ofFiles's File'sSize in Date of lastFilename
Permission fieldLinksOwnerGroupBytesmodification
|||||||
drwxrwxrwx 4georgeteam1122Dec 12 18:02Projects
The fields are as follows:
  1. Type field: The first character in the field indicates a file type of one of the following:
    • d = directory
    • l = symbolic link
    • s = socket
    • p = named pipe
    • - = regular file
    • c= character (unbuffered) device file special
    • b=block (buffered) device file special
  2. Permissions are explained above.
  3. Links: The number of directory entries that refer to the file. In our example, there are four.
  4. The file's owner in our example is George.
  5. The group the file belongs to. In our example, the group is team1.
  6. The size of the file in bytes
  7. The last modification date. If the file is recent, the date and time is shown. If the file is not in the current year, the year is shown rather than time.
  8. The name of the file.

Nenhum comentário:

Postar um comentário