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

Setting Permissions on Mac OS X




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

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

Included in the Article Links to Guides on Getting-Started with Command Line on Mac and to Setting Ownership over Mac File System.

Set/Change Files and Directories Permissions on Mac Command Line - Featured
  1. To

    Open a Terminal Shell emulator window
    Launch Finder:

    Getting-Started Command Line Terminal for Mac 10.12 Sierra - Launch Finder




    Select Applications:

    Getting-Started Command Line Terminal for Mac 10.12 Sierra - Open Applications




    Double-Click on Utilities:

    Getting-Started Command Line Terminal for Mac 10.12 Sierra - Open Utilities




    Double-Click over Terminal:

    Getting-Started Command Line Terminal for Mac 10.12 Sierra - 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 Permissions?

    • You Can Freely Set/Change the Permissions Only on Files/Directories You Hold.
    • You Need Admin Super-Powers to Set/Change the Permissions on Entities You Do Not Hold!
  5. Setting Up Permissions on Files and Directories

      Basic Building Blocks for the Permission Command

      Ownership Types:

      • Use ‘u‘ to Setup Permissions for the User Owner
      • Use ‘g‘ to Setup Permissions for the Group Owner
      • Use ‘u+g‘ to Setup Permissions for the User and Group Owner
      • Use ‘a‘ to Setup Permissions for All (World)
      • Use ‘o‘ for Revoking Actual Permissions and Giving Permissions to the Others (the Before Disabled ones)

      Permission Types:

      • Use ‘x‘ to Setup Execution Permission
      • Use ‘w‘ to Setup Write/Delete Permission
      • Use ‘r‘ to Setup Read Permission

      Giving/Removing Permissions:

      • Use ‘+‘ to Give Permission
      • Use ‘‘ to Remove Permission

    Generic Permission Command Form:

    chmod ownershipSubject[+/-]r/w/x myEntity

    For Instance :

    mkdir $HOME/world

    To Give ‘All’ (read,write/delete,execute) Permissions on the ‘world’ Directory to the ‘World’:

    chmod a+rwx $HOME/world

    (Normally Take Care Before to Open a Directory to the World Because this Can Compromise Your System Security!)
    Now to Check Permissions Setup:

    ls -l $HOME

    To Remove the ‘Write/Delete’ Permission to the ‘World’:

    chmod a-w $HOME/world

    To Give the ‘Write/Delete’ Permission the ‘world’ Only to the Owner:

    chmod u+w $HOME/world

    To Give the ‘Write/Delete’ Permission the ‘world’ Also to the Owner’s Group:

    chmod g+w $HOME/world

    To Remove the ‘Execution’ Permission to the ‘World’:

    chmod a-x $HOME/world

    To Give the ‘Execution’ Permission to the ‘world’ to the Owner:

    chmod u+x $HOME/world

    To Give the ‘Execution’ Permission to the ‘world’ Also to the Owner’s Group:

    chmod g+x $HOME/world

    (After Only You and Your Group will be Able to Access the ‘world’ Directory Directory on Shell!)

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

    Mac Setting Ownership Quick-Start