Bookmark this page

Guided Exercise: Managing File Permissions

Identify and update file permissions.

Outcomes

  • Modify file permissions to grant permissions to different sets of users.

As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.

[student@workstation ~]$ lab start users-permissions

Instructions

  1. In the Files application, navigate to the /Expenses directory. Review the file permissions of the /Expenses/July directory.

    1. Open the Files application, click Other Locations, and then select Computer. Double-click the Expenses directory.

    2. Right-click the July directory, and select Properties from the context menu. Click Permissions to review the directory permissions.

      The student user has read, write, and execute permissions on the directory. The group and others user sets do not have permissions for this directory.

  2. On the command line, review the permissions on the /Expenses/July directory. Grant the Operations group permissions to read and write in the /Expenses/July directory and its contents. Maintain the current rwx permission set for the user, and maintain the --- permission set for the others.

    Use sudo privileges with the chmod command to set the new permissions.

    1. On the command line, review the permissions of the /Expenses/July directory.

      [student@workstation ~]$ ls -ld /Expenses/July/
      drwx------. 2 student Operations 152 Nov  5 22:14 /Expenses/July/
    2. Review the permissions of the files in the /Expenses/July directory.

      [student@workstation ~]$ ls -l /Expenses/July/
      total 0
      -rw-------. 1 developer2 Operations 0 Nov  5 22:53 developer2_expenses.txt
      -rw-------. 1 developer3 Operations 0 Nov  5 22:53 developer3_expenses.txt
      -rw-------. 1 manager    Operations 0 Nov  5 22:53 manager_expenses.txt
      -rwxr--r--. 1 student    Operations 0 Nov  5 22:53 review_files.sh
      -rw-rw-rw-. 1 student    Operations 0 Nov  5 22:53 student_expenses.txt
      -rw-------. 1 tester2    Operations 0 Nov  5 22:53 tester2_expenses.txt
    3. Grant the Operations group permission to read and write on the /Expenses/July directory. Maintain the current rwx permission set for the user, and maintain the --- permission set for the others

      [student@workstation ~]$ chmod 0760 /Expenses/July/
      [student@workstation ~]$ ls -ld /Expenses/July/
      drwxrw----. 2 student Operations 152 Nov  5 22:14 /Expenses/July/
  3. The /Expenses/July/student_expenses.txt file has read and write permissions for all users. Set the appropriate permissions to the /Expenses/July/student_expenses.txt file so that only the student user can write to the file.

    1. Review the permissions on the student_expenses.txt file.

      [student@workstation ~]$ ls -l /Expenses/July/student_expenses.txt
      -rw-rw-rw-. 1 student Operations 0 Nov  5 22:53 /Expenses/July/student_expenses.txt
    2. Set the permissions so that only the student user can write the file.

      [student@workstation ~]$ chmod 0600 /Expenses/July/student_expenses.txt
      [student@workstation ~]$ ls -l /Expenses/July/student_expenses.txt
      -rw-------. 1 student Operations 0 Nov  5 22:53 /Expenses/July/student_expenses.txt
  4. Set the appropriate permissions for the /Expenses/July/review_files.sh script so that all users in the system can execute it.

    1. Review the permissions on the review_files.sh file.

      [student@workstation ~]$ ls -l /Expenses/July/review_files.sh
      -rwxr--r--. 1 student Operations 0 Nov  5 23:02 /Expenses/July/review_files.sh
    2. Set the permissions so that all users can execute the review_files.sh script.

      [student@workstation ~]$ chmod 755 /Expenses/July/review_files.sh
      [student@workstation ~]$ ls -l /Expenses/July/review_files.sh
      -rwxr-xr-x. 1 student Operations 0 Nov  5 23:02 /Expenses/July/review_files.sh

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish users-permissions

Revision: rh104-9.1-3d1f2bc