Linux File Permissions u0026 Ownership Quiz Quiz

Explore your understanding of Linux file permissions, ownership concepts, and command usage. This quiz covers access levels, permission changes, ownership transfers, and special permission bits to help you solidify your foundation in Linux security and file management.

  1. Understanding Basic File Permissions

    In a typical Linux system, what does the permission string '-rwxr-xr--' indicate for a file owned by 'alice' in her home directory?

    1. Only the owner has all permissions; others have no permissions.
    2. Owner can read and write; group can write and execute; others can execute only.
    3. Everyone can read, write, and execute the file.
    4. Owner can read, write, and execute; group can read and execute; others can read only.

    Explanation: The string '-rwxr-xr--' breaks down to owner (rwx), group (r-x), and others (r--). This means the owner has all three permissions (read, write, execute), the group has read and execute permissions, and others can only read. 'Everyone can read, write, and execute' is incorrect because write and execute are not granted for all. 'Only the owner has all permissions; others have no permissions' overlooks group and others' permissions. The last option inaccurately assigns write and execute permissions in the group and others sections.

  2. Changing Ownership

    Which command would change the owner of the file 'project.txt' to user 'bob' and the group to 'devs'?

    1. chown bob:devs project.txt
    2. chown devs:bob project.txt
    3. chgrp bob:devs project.txt
    4. chmod bob:devs project.txt

    Explanation: The correct command is 'chown bob:devs project.txt', where 'bob' becomes the owner and 'devs' the group. 'chmod' changes permissions, not ownership. 'chgrp bob:devs project.txt' is invalid syntax; 'chgrp' changes only the group. 'chown devs:bob project.txt' would set 'devs' as the owner and 'bob' as the group, which is reversed from the goal.

  3. Symbolic vs. Numeric Permissions

    Which of the following commands grants the owner read and write permissions, and removes all permissions from group and others for the file 'secure.dat'?

    1. chmod 644 secure.dat
    2. chmod u+x secure.dat
    3. chmod 600 secure.dat
    4. chmod 777 secure.dat

    Explanation: The mode 600 means owner can read and write, while group and others have no permissions. 'chmod 777' grants all permissions to everyone, which contradicts the requirement. 'chmod u+x' only adds execute for the user but doesn't affect other permissions or users. 'chmod 644' gives read and write to owner and read-only to group and others.

  4. Special Permission Bits

    What is the effect of setting the sticky bit on a directory such as '/public'?

    1. Files within the directory become executable by all users.
    2. Only the file's owner or root can delete or rename files within the directory.
    3. Everyone can delete any files in the directory regardless of ownership.
    4. The directory can only be accessed by its group owner.

    Explanation: The sticky bit restricts deletion and renaming of files within a directory to only the file owner or root, commonly used for shared directories. Without the sticky bit, users could delete each other's files if permissions allow. Making files executable by all users is not related to the sticky bit; that's controlled by execute permissions. Limiting access to the group owner would involve permissions or group settings, not the sticky bit.

  5. Default File Creation Permissions (umask)

    If a user's umask is set to 027, what will be the default permissions for a newly created file?

    1. 640
    2. 777
    3. 666
    4. 755

    Explanation: A umask of 027 removes write for group and all permissions for others from the default 666 file permissions, resulting in 640 (owner read/write, group read, others none). 755 is a common default for directories, not files. 666 would mean everyone can read and write, which the umask restricts. 777 is all permissions for everyone, which is not allowed by the umask.