Search code examples
shellpermissionspermission-denied

Changing folder permissions from command line (on mac)


I'm trying to write a script that will let me add to an existing directory structure and copy a bunch of files into various places within this. However, using mkdir ... and cp... commands alone wont work since I do not have permission to do so. I understand that this can be changed manually in the 'Get Info' window, but this script will be run by others and its whole point is to save time and hassle.

Is there a way of adding to this script to give me permission to copy files to BASEDIR/SUBDIRS?

A bit more detail on what I'm doing:
I want to add to the directory BASEDIR with a bunch of SUBDIRS then copy files into these subdirectories. The problem is that I am receiving these 'permission denied' errors right after the mkdir BASEDIR/SUBDIR1/SUBDIR2 command.

Thanks


Solution

  • The command
    sudo chmod -R ugo=rwx BASEDIR/
    gives all folder permissions to all users to BASEDIR and all its subdirectories