โ† All 010-160 Flashcard Decks

File Permissions and Ownership Flashcards

6 cards from real 010-160 practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 File Permissions and Ownership flashcards as text
  1. A system administrator needs to set the permissions for a shell script named `deploy.sh`. The requirements are that the owner can read, write, and execute it; members of the group can read and execute it; and all other users can only read it. Which of the following `chmod` commands will set these permissions correctly using octal notation?

    Answer: chmod 754 deploy.sh

    In octal notation, read is 4, write is 2, and execute is 1. The permissions are calculated for owner, group, and other. Owner (read+write+execute) = 4+2+1=7. Group (read+execute) = 4+1=5. Other (read) = 4. Therefore, the correct octal code is 754.

  2. Which command is used to change the ownership of `file.txt` to the user `anne` and the group `developers` in a single operation?

    Answer: chown anne:developers file.txt

    The `chown` command is used to change file ownership. The syntax `chown user:group filename` allows changing both the user owner and the group owner simultaneously.

  3. A user runs the `umask 0027` command. What will the default permissions be for a newly created directory afterwards?

    Answer: drwxr-x---

    The system starts with default permissions for a directory, which is 777 (`rwxrwxrwx`). The `umask` value is subtracted from this default. 777 - 027 results in 750. This octal value corresponds to `rwxr-x---`.

  4. What is the primary function of the execute (`x`) permission when it is set on a directory?

    Answer: It allows a user to enter the directory with the `cd` command.

    For a directory, the execute (`x`) permission grants the ability to traverse it or enter it, for example, by using the `cd` command. Listing contents requires read (`r`) permission, and modifying the directory's contents (creating/deleting files) requires write (`w`) permission.

  5. A file has the permissions `-rw-r--r--`. The owner wants to add write permission for the group members without affecting any other permissions. Which of the following commands will achieve this?

    Answer: chmod g+w file.txt

    The symbolic notation `g+w` specifically targets the 'group' (`g`) and 'adds' (`+`) the 'write' (`w`) permission. Using octal `664` would work in this specific case, but it resets all permissions rather than just adding one. The `g+w` syntax is the most precise way to add a permission without altering others.

  6. After running `ls -l`, you see the following output for a file: `-rwxr-x--- 1 student staff 4096 Mar 18 12:00 mydata`. What can a user who is a member of the `staff` group do with this file?

    Answer: Read and execute the file.

    The permission string `-rwxr-x---` is divided into three sets after the initial character: owner (rwx), group (r-x), and other (---). The group permissions are `r-x`, which means members of the `staff` group can read the file and execute it, but they cannot write to it.

File Permissions and Ownership Flashcards โ€” 010-160 Study Cards with Answers