<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need a script to set user dirs back to correct owner in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019215#M96929</link>
    <description>&amp;gt;&amp;gt;Warning - using Dough solution as-it-is will lead to system corruption!&lt;BR /&gt;&lt;BR /&gt;You might consider rereading the code before coming out with statements like that.&lt;BR /&gt;&lt;BR /&gt;awk -F: '$6 ~ /home/ {...}&lt;BR /&gt;&lt;BR /&gt;Says if the 6th field, the home directory in this case, has home in it, then print out the format...&lt;BR /&gt;&lt;BR /&gt;The whole point of echo'ing the output for the first run is also to ensure it's only geting what it's supposed to - just in case some app home directory is /opt/home_app.&lt;BR /&gt;&lt;BR /&gt;Believe it or not, I have done this a time or two...&lt;BR /&gt;&lt;BR /&gt;Doug</description>
    <pubDate>Sat, 16 Dec 2006 13:40:43 GMT</pubDate>
    <dc:creator>Doug O'Leary</dc:creator>
    <dc:date>2006-12-16T13:40:43Z</dc:date>
    <item>
      <title>Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019206#M96920</link>
      <description>Hey everyone,&lt;BR /&gt;&lt;BR /&gt;Somewhere along the way our perms got mixed up in /home.  I would like a script that would let me quickly change all the users in /home so that they own their own dirs.  Any ideas?  Thanks.</description>
      <pubDate>Fri, 15 Dec 2006 23:45:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019206#M96920</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2006-12-15T23:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019207#M96921</link>
      <description>What does it mean to "change all the users"?&lt;BR /&gt;(Or to change a user?)&lt;BR /&gt;&lt;BR /&gt;Do you want to change the ownership of some&lt;BR /&gt;directories?&lt;BR /&gt;&lt;BR /&gt;Do you want to change the ownership of all the files in a directory tree, or just of the&lt;BR /&gt;directory?&lt;BR /&gt;&lt;BR /&gt;How do you know who owns a directory?&lt;BR /&gt;&lt;BR /&gt;Stating a problem clearly can lead more&lt;BR /&gt;quickly to a solution.</description>
      <pubDate>Sat, 16 Dec 2006 01:01:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019207#M96921</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2006-12-16T01:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019208#M96922</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;unfortunately, you cannot "undo" this change. Unless you recover from backup the files that have not changed since the error had occurred, you will have to set the owner and group manually.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;good luck&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Sat, 16 Dec 2006 01:45:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019208#M96922</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2006-12-16T01:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019209#M96923</link>
      <description>&amp;gt; [...] you cannot "undo" this change.&lt;BR /&gt;&lt;BR /&gt;With enough information and effort, you can&lt;BR /&gt;undo _any_ change.&lt;BR /&gt;&lt;BR /&gt;"chown" will change the ownership of one or&lt;BR /&gt;more files, but you need to know which owner&lt;BR /&gt;to set for which files.&lt;BR /&gt;&lt;BR /&gt;When we get enough information to know what&lt;BR /&gt;the actual work to be done is, it should be&lt;BR /&gt;possible to say how much effort is actually&lt;BR /&gt;needed to do it.  (And how much critical&lt;BR /&gt;information is missing.)</description>
      <pubDate>Sat, 16 Dec 2006 02:07:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019209#M96923</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2006-12-16T02:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019210#M96924</link>
      <description>&lt;!--!*#--&gt;&amp;gt;would like a script that would let me quickly change all the users in /home so that they own their own dirs.&lt;BR /&gt;&lt;BR /&gt;If you want to just do that for the directories and each home directory is the same as the user, you can do:&lt;BR /&gt;&lt;BR /&gt;for dir in /home/*; do&lt;BR /&gt;   dir_base=$(basename $dir)&lt;BR /&gt;   chown $dir_base $dir&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;You don't mention if the group ownership was also messed up?&lt;BR /&gt;&lt;BR /&gt;You could grep the passwd file to make sure each owner exists too.  And find the proper group, if needed.</description>
      <pubDate>Sat, 16 Dec 2006 07:46:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019210#M96924</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-12-16T07:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019211#M96925</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Knowing *what* you did to your '/home' directory will certainly dictate the kind of attack necessary to fix it.&lt;BR /&gt;&lt;BR /&gt;Did you inadvertantly 'chown -R' when your currently working directory was at '/home'?&lt;BR /&gt;&lt;BR /&gt;Did you change both the ownership and the group membership or did you just change the group membership with 'chgrp'?&lt;BR /&gt;&lt;BR /&gt;If you only changed the owner of directories and files within '/home', a solution like Dennis's will work.  If you changed both the ownership and group membership of directories and files within '/home', then I'd parse '/etc/passwd'; extract the account name and 'gid' from each record of the file; and 'chown -R name:gid /home/name' accordingly.  A pure shell script can accomodate this easily.&lt;BR /&gt;&lt;BR /&gt;*IF* you have changed both the owner and group membership of directories and files within '/home' *and* you have a significant number of files within that have different group memberships even within an account; *and* can't restore a backup; then consider restoring a backup copy of your '/home' directory to a temporary directory.  Then, programatically examine the temporary directory and issue commands to change the *current* files ownership and group membership to match that of the temporarily restored set.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 16 Dec 2006 10:59:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019211#M96925</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-16T10:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019212#M96926</link>
      <description>for user in `cat /etc/passwd |awk -F: '{print $1}'`&lt;BR /&gt;do&lt;BR /&gt;chown $user /home/$user&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Or add the recursise to the chown:&lt;BR /&gt;&lt;BR /&gt;chown -R $user /home/$user&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Sat, 16 Dec 2006 12:31:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019212#M96926</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-12-16T12:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019213#M96927</link>
      <description>Hey&lt;BR /&gt;&lt;BR /&gt;awk -F: '$6 ~ /home/ {printf("%s:%d %s", $1, $5, $6)}' /etc/passwd | \&lt;BR /&gt;while read owner home&lt;BR /&gt;do&lt;BR /&gt;   echo chown -R ${owner} ${home}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;If the script prints out what you think it should, remove the echo.&lt;BR /&gt;&lt;BR /&gt;hth;&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Sat, 16 Dec 2006 12:54:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019213#M96927</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-12-16T12:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019214#M96928</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Warning - using Dough solution as-it-is will lead to system corruption!&lt;BR /&gt;&amp;lt;&amp;lt;&lt;BR /&gt;awk -F: '$6 ~ /home/ {printf("%s:%d %s", $1, $5, $6)}' /etc/passwd | \&lt;BR /&gt;while read owner home&lt;BR /&gt;do&lt;BR /&gt;echo chown -R ${owner} ${home}&lt;BR /&gt;done&lt;BR /&gt;&amp;gt;&amp;gt;&lt;BR /&gt;&lt;BR /&gt;Since /etc/passwd contains system accounts as well, one command would be something like&lt;BR /&gt;chown -R sys:sys /&lt;BR /&gt;&lt;BR /&gt;You won't execute that.&lt;BR /&gt;&lt;BR /&gt;However the idea is correct - you just have to exclude some accounts, e.g.&lt;BR /&gt;&lt;BR /&gt;awk -F: '$6 ~ /home/ {printf("%s:%d %s", $1, $5, $6)}' /etc/passwd | \&lt;BR /&gt;while read owner home&lt;BR /&gt;do&lt;BR /&gt;[ home = / ] &amp;amp;&amp;amp; continue&lt;BR /&gt;echo chown -R ${owner} ${home}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;A check for uid &amp;gt;100 (or so) is not bad, as well.&lt;BR /&gt;&lt;BR /&gt;Some other hints:&lt;BR /&gt;- When using NIS, instead of reading /etc/passwd you can use 'ypcat passwd'.&lt;BR /&gt;- Permissions for NFS-mounted homes can only be changed, when root access to the NFS server is enabled.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sat, 16 Dec 2006 13:14:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019214#M96928</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-12-16T13:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019215#M96929</link>
      <description>&amp;gt;&amp;gt;Warning - using Dough solution as-it-is will lead to system corruption!&lt;BR /&gt;&lt;BR /&gt;You might consider rereading the code before coming out with statements like that.&lt;BR /&gt;&lt;BR /&gt;awk -F: '$6 ~ /home/ {...}&lt;BR /&gt;&lt;BR /&gt;Says if the 6th field, the home directory in this case, has home in it, then print out the format...&lt;BR /&gt;&lt;BR /&gt;The whole point of echo'ing the output for the first run is also to ensure it's only geting what it's supposed to - just in case some app home directory is /opt/home_app.&lt;BR /&gt;&lt;BR /&gt;Believe it or not, I have done this a time or two...&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Sat, 16 Dec 2006 13:40:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019215#M96929</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-12-16T13:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019216#M96930</link>
      <description>Sorry Dough,&lt;BR /&gt;&lt;BR /&gt;missed that!&lt;BR /&gt;&lt;BR /&gt;I was remembered by this to a holiday call to myself as 'request for rescue' by such an incident (which ended in a re-install).&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sat, 16 Dec 2006 13:48:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019216#M96930</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-12-16T13:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need a script to set user dirs back to correct owner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019217#M96931</link>
      <description>Thanks everyone.</description>
      <pubDate>Mon, 18 Dec 2006 17:49:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-script-to-set-user-dirs-back-to-correct-owner/m-p/5019217#M96931</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2006-12-18T17:49:54Z</dc:date>
    </item>
  </channel>
</rss>

