I'm trying to develop a Perl script to look for orphaned homes (home directories without users, or the inverse). This script should generate a formatted listing of any user without a home directory... ...or any home directory (a directory in /home) that is not attached to a user. The identifying element is the UID, not the username. I need to understand the difference between running the program as root as well as running it without root privileges

I'm using file handles to grab information from the OS about homes and users -- and put that information into arrays. The script would essentially be running external shell processes and reading from those processes' output just like reading from a text file. This code, will be executed on a standard Linux OS.

Array for the users
open (USERS, '-|' , 'getent passwd' ) or die $!; @passwd_entries = <USERS>;
Array for the homes
open (HOMES, '-|' , 'ls /home' ) or die $!; @home_dirs = <HOMES>; close HOMES;

In reply to List users without homes and homes without users by codeout

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.