File ownership in Linux

What two factors determine what files and directories user can access in Linux?
The two factors that determine what files and directories a user can access in Linux are:

  1. File ownership.
  2. File permission.

What are the three types of owners in Linux?
The three types of owners in Linux are:

  1. User - The user is the owner of the file.
  2. Group - Other users who are in the same group as the owner.
  3. Other - All of the other users on the system.

File permissions in Linux

What are the three different file permissions available for all three types of owners?
The three different file permissions available for all three types of owners are:

  1. Read - The ability to view and copy the data.
  2. Write - The ability to modify the data.
  3. Execute - The ability to run the data if it's executable.

What are the three different directory permissions available for all three types of owners?
The three different directory permissions available for all three types of owners are:

  1. Read - The ability to list and copy all files from the directory.
  2. Write - The ability to add files to or delete files in the directory.
  3. Execute - The ability to enter the directory.

Does an owner need execute permissions in order to write to a directory?
Yes, an owner needs execute permissions in order to write to a directory.

Understanding file permissions and ownership in Linux

What two commands can you use to see the permissions of a file or directory?
Two commands you can use to see the permissions of a file or directory are:

  1. stat.
  2. ls -l.

What is the format of the output of the ls -l command?
The format of the output of the ls -l command is:
Output Format of the ls-l Command.png

What are the possible file type indicators?
The possible file type indicators are:

  1. d - Directory.
  2. - - Regular file.
  3. l - Symbolic link.

In what units is the file size?
The file size is in bytes.

What are the meanings letters mean in the permissions section?
In the permissions section, the meanings of the letters are:

  • r - Read permission.
  • w - Write permission.
  • x - Execute permission.
  • - - No permission set.

For which user do the first three letters of the permissions section refer to?
The first three letters of the permissions section refer to the user owner.

For which user do the middle three letters of the permissions section refer to?
The middle three letters of the permissions section refer to other users in the same group as the user owner.

For which user do the last three letters of the permissions section refer to?
The last three letters of the permissions section refer to all other users on the system.

What can the root user do normally to all files regardless of permissions?
Regardless of permissions, the root user can normally read, write, and execute all files.

If a user belongs to multiple groups, to which group do the group permissions for a file created by the user apply?
If a user belongs to multiple groups, the group permissions for a file created by the user apply to the primary group of the user.

How do you find the primary group of a user?
To find the primary group of a user, run id -gn <username>.

Change file permissions in Linux

Which program is used to change the permissions for a file or directory in Linux?
In Linux, the program used to change the permissions for a file or directory is chmod.

Why is the program called chmod?
The program is called chmod because the original name for permissions on Linux was "mode of access," and so chmod was short for "change mode of access."

What are the two modes you can use chmod?
The two modes you can use chmod are:

  1. Absolute mode.
  2. Symbolic mode.

Using chmod in absolute mode

How are file permissions represented in absolute mode?
In absolute mode, permissions are represented as octal numbers.

What are the numbers that represent each permission?
The numbers that represent each permission are:

  • Read - 4.
  • Write - 2.
  • Execute - 1.
  • No permission - 0.

What is the table for all the possible combinations of permissions in absolute mode?
The table for all the possible combinations of permissions in absolute mode is:

Number Permission
0 ---
1 --x
2 -w-
3 -wx
4 r--
5 r-x
6 rw-
7 rwx

...