title: Vagrant: How to set the default owner and group permissions
body: <p>While creating a Ubuntu VM, I am providing a provisioning script to install some of the packages once the guest OS is installed. </p>
  
  <pre><code>config.vm.provision :shell, :path =&gt; "vm_provision/provision-node01.sh"
  </code></pre>
  
  <p>The bash script contains: </p>
  
  <pre><code>#!/usr/bin/env bash
  
  # Intended for Ubuntu 14.04 (Trusty)
  
  # Update the Ubuntu
  sudo apt-get -y update
  sudo apt-get -y install build-essential
  
  mkdir zookeeper
  https://github.com/apache/zookeeper
  </code></pre>
  
  <p>The VM gets created as well as above shell script commands are also executed fine. However, the default owner and the group permission to the folder 'zookeeper' is both set to the root.</p>
  
  <pre><code>vagrant@ubuntu-14:~$ ls -lrt
  total 4
  drwxr-xr-x 4 root root 4096 Mar 30 08:55 zookeeper
  </code></pre>
  
  <p>I want it to be vagrant  vagrant so that  I do not have change to super user all the time.</p>
  
  <p>There are steps provided for setting the owner/group permission for the shared folder, but that is set via Vagrantfile. <a href="https://stackoverflow.com/questions/13566201/can-i-modify-the-ownership-for-a-shared-folder-in-vagrant">Vagrant sync folder creation</a></p>
  
  <p>In my provisioning shell script, I tried changing the user (like below) before creating the folder and cloning the github repo, but that did not help. </p>
  
  <pre><code>su - vagrant
  </code></pre>