Understanding default ownership

When we create a file or directory, it gets certain default ownership and group ownership. The user who creates the file becomes the user (owner) of that file, and the primary group of that user becomes the group of that file. To find out whether a user or a group has the permissions to access a file or a directory, a shell checks the ownership of that file in the following order:

  1. When accessing a file, a shell checks whether you are the owner of a file. If a user is the owner of a file, then the user gets access to the file with the permissions that are set for the owner of the file.
  2. If the user is not the owner of the file, a shell checks for the group of the file. If the user is a member of a group assigned to the file, then he gets access to the file with the permissions that are set for the group of the file.
  3. If the user is neither the owner of the file and doesn't belong to the group assigned to the file, then the user gets access to the file with other permissions.

The long-listing ls -l command is used to view the current ownership of the file. The third and fourth fields of output of the long-listing command display the owner and group of the file, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.2.184