File Permissions and Ownership Essentials in CLI Quiz

Explore core concepts of file permissions and ownership in the command-line interface, including permission notation, user roles, and key commands. Test your knowledge on managing access rights and securing files in CLI environments with realistic scenarios.

  1. Understanding Symbolic Permissions

    Given the output '-rw-r--r--' for a file, what does this indicate about who can write to the file?

    1. Only the owner can write to the file.
    2. Anyone can write to the file.
    3. Only the group can write to the file.
    4. Everyone can write and execute the file.

    Explanation: The '-rw-r--r--' notation means the owner has read and write permissions, the group has read-only, and others also have read-only permission. Therefore, only the file's owner can write to it. The group and others do not have write access, so 'Anyone can write' and 'Everyone can write and execute' are incorrect. The 'Only the group can write to the file' option is also wrong, as only the owner has write rights.

  2. Changing Ownership

    Which command allows you to change the group ownership of a file named 'report.txt' to the group 'staff'?

    1. chgrp staff report.txt
    2. chmod staff report.txt
    3. chown staff: report.txt
    4. setgrp staff report.txt

    Explanation: The 'chgrp' command changes the group ownership of a file. While 'chown staff: report.txt' may seem plausible, it changes both owner and group only if used as 'chown :staff report.txt'. 'chmod' is for permissions, not ownership. 'setgrp' is not a valid CLI command, making 'chgrp staff report.txt' the correct choice.

  3. Numerical Permission Notation

    What does the numeric permission '750' mean for a directory?

    1. Owner: all permissions; Group: read and execute; Others: no permission.
    2. Owner: read, write, execute; Group: read and execute; Others: no permission.
    3. Owner: read, write; Group: execute only; Others: read only.
    4. Owner: execute only; Group: read and write; Others: execute only.

    Explanation: In '750', 7 stands for read, write, and execute for the owner; 5 is read and execute for the group; 0 is no permissions for others. 'Owner: all permissions; Group: read and execute; Others: no permission.' is too vague about the actual permissions. The other distractors mix up or misrepresent the specific rights granted by each digit.

  4. Modifying User Permissions

    Which command would remove write permissions for the group on a file called 'data.csv'?

    1. chmod g-w data.csv
    2. chmod u-w data.csv
    3. chown g-w data.csv
    4. chgrp -w data.csv

    Explanation: 'chmod g-w data.csv' removes (the minus) write permission (w) from the group (g). 'chmod u-w' would affect the user, not the group. 'chown' changes ownership, not permissions, so 'chown g-w' is incorrect. 'chgrp -w' is not a valid syntax for modifying file permissions, making 'chmod g-w' the correct answer.

  5. Interpreting Default Ownership

    When a user creates a new file in their home directory, who is set as the file's owner and group by default?

    1. The user is both the owner and the group.
    2. The system administrator is the owner; the user is the group.
    3. The user is the owner; the group is typically the user's default group.
    4. The owner and group fields are left empty until explicitly set.

    Explanation: By default, the file's owner is the user who created it, and the group is the user's primary or default group. The first option is close but less accurate since the group could include others or be a group with the user's name. The administrator is not set by default, so option two is incorrect. Ownership fields are never left empty, making option four unsuitable.