use User::pwent; my $username = 'f00li5h'; my $user = getpwnam($username); printf "%s aka (%s) lives in %s $/", $user->name, $user->gecos, $user->dir; #f00li5h aka (f00li5h and5illy) lives in /home/f00li5h use File::Spec; my @paths = File::Spec->splitdir( $user->dir ); # start at the most specific directory (/home/f00li5h) head # to the lest specific (/) while( @paths ){ # get the system to mount (rather than just print) printf "mount %s $/", File::Spec->catdir( @paths ); last if -d $user->dir; # stop looking when the dir turns up pop @paths ; }