title: How to call user/group IDs in Linux bash scripts
body: <p>I have this bash script. I run it with the following command: <code>sudo ./install.sh</code></p>
  
  <pre><code>#!/bin/bash
  
  MYSQL_PASS="password"
  
  USER="500"
  SUPERUSER="0"
  
  sudo -u ${USER} echo -e "Installing docker-compose from GitHub Latest release..." \
  \
  &amp;&amp; sudo -u ${SUPERUSER} mkdir -p /opt/bin \
  &amp;&amp; sudo -u ${SUPERUSER} curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` &gt; /opt/bin/docker-compose \
  &amp;&amp; sudo -u ${SUPERUSER} chmod +x /opt/bin/docker-compose \
  &amp;&amp; sudo -u ${USER} echo -e "docker-compose installed, verifying..." \
  &amp;&amp; sudo -u ${USER} docker-compose -v \
  \
  &amp;&amp; sudo -u ${USER} echo -e "Creating folder structure..." \
  &amp;&amp; sudo -u ${USER} mkdir -p ~/mysql ~/sqlbackup ~/work/lemp ~/www \
  \
  &amp;&amp; sudo -u ${USER} echo -e "Cloning git repo into \"~/work/lemp\"..." \
  &amp;&amp; sudo -u ${USER} git clone https://github.com/DJviolin/LEMP.git ~/work/lemp \
  \
  &amp;&amp; sudo -u ${USER} echo -e "Showing working directory..." \
  &amp;&amp; sudo -u ${USER} ls -al ~/work/lemp \
  \
  &amp;&amp; sudo -u ${USER} echo -e "Starting docker images and containers generation..." \
  &amp;&amp; sudo -u ${USER} echo -e "\
  # Set MySQL Root Password\n\
  MYSQL_ROOT_PASSWORD=${MYSQL_PASS}" &gt; ~/work/lemp/mariadb/mariadb.env \
  &amp;&amp; sudo -u ${USER} cat ~/work/lemp/mariadb/mariadb.env \
  &amp;&amp; sudo -u ${USER} docker-compose build ~/work/lemp \
  \
  &amp;&amp; sudo -u ${USER} echo -e "LEMP stack has built...\nRun the service with ./service-start.sh command." \
  &amp;&amp; sudo -u ${USER} echo -e "All done! Exiting..."
  </code></pre>
  
  <p>Calling the user <code>core</code> as <code>500</code> and <code>root</code> as <code>0</code> not working. I've got the following error:</p>
  
  <pre><code>sudo: unknown user: 500
  sudo: unable to initialize policy plugin
  </code></pre>
  
  <p>The reason why I want to use user or group numbers, because I want to make it multiplatform (would be nice if it can choose between 500 or 1000, because I read some linux distros' default user is 1000, but in my case is 500).</p>
  
  <p>Can we detect which user started to run this script as <code>sudo</code>? Because probably this is the way to go on a multi-user linux.</p>
  
  <p>EDIT:</p>
  
  <p>This is the script without the need of the superuser privileges, making a new path variable under the user's home folder:</p>
  
  <pre><code>#!/bin/bash
  
  set -e
  
  echo -e "Installing docker-compose from GitHub Latest release..."
  
  mkdir -p ~/bin
  curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` &gt; ~/bin/docker-compose
  chmod +x ~/bin/docker-compose
  export PATH="~/bin:$PATH"
  echo -e "docker-compose installed, verifying..."
  docker-compose -v
  
  echo -e "Creating folder structure..."
  mkdir -p ~/mysql ~/sqlbackup ~/work/lemp ~/www
  
  echo -e "Cloning git repo into \"~/work/lemp\"..."
  git clone https://github.com/DJviolin/LEMP.git ~/work/lemp
  
  echo -e "Showing working directory..."
  ls -al ~/work/lemp
  
  echo -e "Starting docker images and containers generation..."
  echo -e "\
  # Set MySQL Root Password\n\
  MYSQL_ROOT_PASSWORD=`openssl rand -base64 37 | sed -e 's/^\(.\{37\}\).*/\1/g'`" &gt; ~/work/lemp/mariadb/mariadb.env
  cat ~/work/lemp/mariadb/mariadb.env
  
  echo -e "LEMP stack has built...\nRun the service with ./service-start.sh command." \
  echo -e "All done! Exiting..."
  </code></pre>