Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Finding Files, and Assigning Permissions and Ownership

Knowing how to work with files in Linux is an integral part of being a sysadmin. We need to be able to find them, give and revoke permissions on them, and assign or reassign ownership. This hands-on lab is going to give us some practice doing all of those things.

Google Cloud Platform icon

Path Info

Clock icon Intermediate
Clock icon 15m
Clock icon Jan 17, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Find Custom Application Files under /opt/myapp and Display a Detailed Listing of Them

    We're going to need elevated privileges for this lab, so once we're logged in let's just become root right off with sudo -i.

    Use the find command to provide a detailed listing of the /opt/ directory:

    find /opt

    Our myapp directory is sitting in there, now let's see what happening in there as far as files go, like who owns them:

    find /opt/myapp -ls

    The root user owns everything. That's not good. We've got to change that.

  2. Challenge

    Change the /opt/myapp Directory to be Owned by the cloud_user and the Group devop

    Use the chown command to change user ownership to the cloud_user and the group devop for the /opt/myapp directory and its contents:

    find /opt/myapp -exec sudo chown cloud_user:devop {} \;

    To test, run find /opt/myapp -ls again, and see if our chown command actually changed ownership on these files.

    It worked. Now we've got some permissions problems though.

  3. Challenge

    Set Permissions for /opt/myapp Files

    Use the chmod command to set rw-rw----, or 660, permissions on all /opt/myapp files, except for the directory itself and the /opt/myapp/ script:

    find /opt/myapp -name "d*" -ok chmod 660 {} \;

    Just type y for each yes/no prompt.

    Next, change permissions on anything that does not start with d (the directory itself and the script):

    find /opt/myapp '!' -name "d*" -ok chmod 770 {} \;

    Again, type y for each yes/no prompt.

  4. Challenge

    Find a Directory under /home Which Is Not Owned by a User or Group

    Use the find command to find any directories in /home files which lack a user and group owner:

    find /home -nouser -nogroup -ls
  5. Challenge

    Execute the chown Command with the find Command

    Find files and directories that were owned by devuser:

    find /home -ls

    Check for anything that doesn't have user or group ownership:

    find /home -nouser -a -nogroup -ls

    Run chown with find to modify files that have no current user or group ownership:

    sudo find /home -nouser -nogroup -exec sudo chown cloud_user:cloud_user {} \;

    Check that we got them all:

    find /home -nouser -a -nogroup -ls

    See if cloud_user owns them now:

    find /home/devuser -ls

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans