Mac How-to Set-Change Ownership on Files and Directories by Command-Line

Mac OS X Setting Ownerships for File/Directory




Hello Mac User! This Tutorial Shows You Step-by-step How-to Setup or Change the Ownership over Files and Directories on Mac OS X BSD/Unix.

The Ownership Decide How is the Owner of Files and Directories on the Mac OS X File System.

To Set the Ownership Over Files and Directories is the First Step in Setting Up Permissions and so Establish a Control and Security over the System.

To Follow the Tutorial You will Need to have a Little Practice to Work on the Mac Console Terminal Command Line.

Setting Ownership on Mac OS X File System - Featured
  1. To

    Open a Terminal Shell emulator window
    Launch Finder:

    Getting-Started Command Line Terminal for Mac OS X - Launch Finder




    Select Applications:

    Getting-Started Command Line Terminal for Mac OS X - Open Applications




    Double-Click on Utilities:

    Getting-Started Command Line Terminal for Mac OS X - Open Utilities




    Double-Click over Terminal:

    Getting-Started Command Line Terminal for Mac OS X - Launch Terminal
  2. Switch to the Bash Shell
    (Press “Enter” to Execute Commands)

    bash
  3. How-to Quick-Start with Command Line on Mac:

    Mac Console Quick-Start
  4. Who Can Set/Change the Ownership?

    Only the Administrators or a Super-User Can Change a File/Directory Ownership!

  5. How to Set/Change the Ownership?

    • To Set/Change Ownership Over a Single File/Directory:

      sudo chown [myUser]:[myGroup] [myEntity]

      Where [myUser] is your’s user Name & [myGroup] is your’s user Primary Group.

      How-to Look Up User Name & Group on Terminal

      Find User Name & Group

      For Instance:

      mkdir -p $HOME/hello/world

      Now to Give the ‘world’ Directory to the ‘root’ User do:

      sudo chown root:admin $HOME/hello/world

      Checking Ownership:

      ls -l $HOME/hello

      You’ll see the List of contained Entities with Type, Owners & Permissions.

    • To Set/Change Permissions Recursively Over a Directory and it’s Content (Subdirectories and Files):

      sudo chown -R [myUser]:[myGroup] [myEntity]

      For Instance:

      sudo touch $HOME/hello/world/happy

      Checking Ownership:

      ls -l $HOME/hello && ls -l $HOME/hello/world

      Now to Get Back the ‘world’ Directory with the ‘happy’ File 🙂

      sudo chown -R [myUser]:[myGroup] $HOME/hello/world

      Check Ownership like Above…

  6. How-to Set Permissions on Mac File System:

    Mac Permissions Quick-Start