title: Jenkins Linux file access or group issue
body: <p>I'm facing a strange file access issue.</p>
  
  <p>Linux system is RedHat 5.5</p>
  
  <p>On this machine, when I log in as the given user: deploy_user, I can see that I have valid access to /path/to/the/folder/subfolder/file.txt </p>
  
  <p><strong>ls -l /path/to/the/folder</strong> shows (this means upto this path I can see contents):</p>
  
  <pre><code>13:50:53 drwxr-x--- 2 root dbgroup    4096 Apr 27 14:38 subfolder
  </code></pre>
  
  <p>and in folder <strong>subfolder</strong>, file.txt has the following access (<em>ls -l</em> output)</p>
  
  <pre><code>13:50:53 -rwxr----- 1 root dbgroup  1620 Dec  9 15:28 file.txt
  </code></pre>
  
  <p>On the server at $ prompt, if I do: <strong>id deploy_user</strong> I see I'm (being <em>deploy_user</em>) in <em>dbgroup</em> (i.e. anyone in <strong>dbgroup</strong> group can change directory to <em>subfolder</em>) and can read the file <em>file.txt</em>.</p>
  
  <p>When I'm running the same commands in a free-style Jenkins job and running the job on this linux machine as a node/slave (where Jenkins connects only to this node/slave as user <strong>deploy_user</strong> using it's SSH keys successfully), I can't cd (change directory) and list or <strong>ls</strong> and read or <strong>cat</strong> this file.</p>
  
  <p><strong>NOTE</strong>: I'm restricting the jenkins job to run on a particular slave (using a label) i.e. it'll run the job only on a given machine (as I mentioned above).</p>
  
  <p>In the jenkins job, all I'm running are the following commands:</p>
  
  <pre><code>echo "I'm `whoami`"
  echo "I'm in: $(id `whoami`)"
  echo
  groups
  echo
  echo "Again, my groups for: $(groups `whoami`)"
  echo
  cat /etc/group | grep "^dbgroup"
  echo
  echo
  cd /path/to/the/folder
  pwd &amp;&amp; echo "It works! upto /path/to/the/folder path in Jenkins job."
  echo
  echo
  cd /path/to/the/folder/subfolder || echo "cd to subfolder - didnt work"
  echo
  ls -l /path/to/the/folder/subfolder/file.txt || echo "ls on file.txt - didn't work"
  echo
  echo "Sleeping for 60 seconds ..." &amp;&amp; sleep 60
  </code></pre>
  
  <p><strong>Main output from Jenkins job is:</strong></p>
  
  <pre><code>13:50:53 I'm - deploy_user
  13:50:53 I'm in: uid=3000(deploy_user) gid=3000(deploy_user) groups=4000(deployer),6001(dba),6081(osinstall),10121(dbgroup)
  13:50:53
  13:50:53 deployer dba osinstall
  13:50:53
  13:50:53 Again, my groups for: deploy_user : deployer dba osinstall dbgroup
  13:50:53
  13:50:53 dbgroup:x:10121:user1,user2,appuser3,svcuser4,deploy_user
  13:50:53
  13:50:53
  13:50:53 /path/to/the/folder
  13:50:53 It works! upto /path/to/the/folder path in Jenkins job.
  13:50:53
  13:50:53
  13:50:53 /tmp/hudson58581.sh: line 7: cd: /path/to/the/folder/subfolder: Permission denied
  13:50:53: cd to subfolder - didnt work
  13:50:53
  13:50:53 ls: /path/to/the/folder/subfolder/file.txt: Permission denied
  13:50:53 ls on file.txt - didn't work
  13:50:53
  13:50:53 Sleeping for 60 seconds ...
  </code></pre>
  
  <p>Any idea why output of <strong>groups</strong> and <strong>groups deploy_user</strong> are different. groups command by defaults works for the current logged in user (which is whoami and it shows I'm deploy_user).</p>
  
  <p>I also checked the groupID in the ls -l output for both subfolder/file.txt and it's 10121</p>
  
  <p>Thanks.</p>