How to create a Folder Structure by a script


I need to create a specific folder hierarchy within a shared folder. In each level of the hierarchy I need to set specific permissions that are not always inherited from the parent folder.
The same structure needs to be created on regular basis. The only difference will be the name of the root folder.

Is there a way in UCS to create such a folder hierarchy by script?
Or can I maybe set up a folder structure as a template and replicated it?

Thanks a lot,


there are several ways to do this. Apart from UCS-mechanics this sounds like you could write a (relatively simple) shell script based on mkdir and chown.
The important question is when and how you want it to be executed:

  • (Semi) automatically based on certain conditions or triggers
  • Manually with the root-folder name as input

If you want it the be run by itself, UCS offers different mechanisms. Could you explain your Use Case?

Hi jlk,

I don’t need the folders to be created by some trigger. Running a shell script manually will do the job. But I’m not aware how to set the permissions on the folders and sub-folders. Can I use the groups that are defined in the AD and just set them on the folders?

I mad a simple picture of the structure that I need to create:


All folders are pre-defined and should not be editable. For each new customer the same structure shall be created. The groups (management, sales, production) exist in the AD. How do I set these group permissions within the script?

Thanks a lot,

If a AD-Group is 1. synced to the UCS-LDAP und 2. belongs to the PosixGroup class, you can simply change the permission via chown like

chown -R :"Management Group" CUSTOMERS/AGENT_1/Customer_xy/MANAGEMENT

To verify if this is appliable you can run

getent group

Premissions based on owner and ownergroup can be set via chmod.

Another more modular approach would be to use an ACL, you can have a look at or for this.

1 Like

Thanks, this is very helpful!