Bookmark this page

Guided Exercise: User Accounts and File Ownership

Modify file and directory ownership.

Outcomes

  • Identify membership information for user accounts.

  • Update the ownership of files and directories.

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-accounts

Instructions

  1. Log out of the student user session and log in as the sales01 user. Use redhat as the password.

    1. From the system menu, select Power Off/Log Out > Log Out. Confirm the operation by clicking Log Out.

    2. On the login screen, select the sales01 user and use redhat as the password.

    3. Open a terminal.

  2. View the group membership of the sales01, sales05, and sales12 users. Identify the group that the sales01, sales05, and sales12 users have in common.

    1. View the group membership of the sales01 user.

      [sales01@workstation ~]$ groups sales01
      sales01 : sales01 emea hybrid sales-team
    2. View the group membership of the sales05 user.

      [sales01@workstation ~]$ groups sales05
      sales05 : sales05 latam remote sales-team
    3. View the group membership of the sales12 user.

      [sales01@workstation ~]$ groups sales12
      sales12 : sales12 na remote sales-team

      According to the group information, the three users have the sales-team group in common.

  3. View the owner information of the /Finance/Sales-Reports directory. Try to set the sales-team group as the owner of the /Finance/Sales-Reports directory and its contents.

    1. View the long listing information of the /Finance/Sales-Reports directory.

      [sales01@workstation ~]$ ls -ld /Finance/Sales-Reports
      drwxr-xr-x. 2 root root 34 Oct 31 23:46 /Finance/Sales-Reports
    2. Try to set the sales-team group as the owner of the /Finance/Sales-Reports directory and its contents.

      [sales01@workstation ~]$ chown -R :sales-team /Finance/Sales-Reports/
      chown: changing group of '/Finance/Sales-Reports/January': Operation not permitted
      chown: changing group of '/Finance/Sales-Reports/April': Operation not permitted
      chown: changing group of '/Finance/Sales-Reports/': Operation not permitted

      The command fails because the sales01 user is not the owner of the Sales-Reports directory. This user does not have permissions to modify the owner of the directory.

  4. Verify the sudo privileges of the sales01 user. Use your sudo privilege for the chown command to set the sales-team group as the owner of the /Finance/Sales-Reports directory.

    1. Verify the sudo privileges of the sales01 user.

      [sales01@workstation ~]$ sudo -l
      [sudo] password for sales01: redhat
      ...output omitted...
      
      User sales01 may run the following commands on workstation:
          (root) /bin/chown * /Finance/*
    2. Use your sudo privilege for the chown command to set the sales-team group as the owner of the /Finance/Sales-Reports directory.

      [sales01@workstation ~]$ sudo chown -R :sales-team /Finance/Sales-Reports/
    3. Verify that the sales-team group is the owner of the /Finance/Sales-Reports directory.

      [sales01@workstation ~]$ ls -ld /Finance/Sales-Reports
      drwxr-xr-x. 2 root sales-team 34 Oct 31 23:46 /Finance/Sales-Reports
  5. Log out of the sales01 user session and log in as the student user. Use student as the password.

    1. From the system menu, select Power Off/Log Out > Log Out. Confirm the operation by clicking Log Out.

    2. On the login screen, select the student user and use student as the password.

    3. Open a terminal.

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-accounts

Revision: rh104-9.1-3d1f2bc