We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Chown

So when do you need to use sudo? chmod allows you to change the permissions of any file or directory that you own. But what if you don't own the file or directory? That's where sudo is required. Let's change ownership of a directory to see how that works.

The chown command, which stands for "change owner," allows you to change the owner of a file or directory, and it requires root privileges.

Assignment

  1. Hmmm, it seems like it has some personal contact info for employees. We don't know whose this is, but we're pretty sure it should have its access strictly limited.

  2. sudo chown -R root contacts
    

    Here's an explanation of the command:

    • sudo – Run as the root user
    • chown – Command to change the owner
    • -R – "Recursive," meaning also apply the changes to everything inside the directory
    • root – The name of the new owner
    • contacts – The directory to change the owner of

    You might be prompted for your password. Enter it.

  3. ls -l
    

Find the line from the output that represents the contacts directory. Copy the whole line into the input field and submit your answer.