File::lchown(3pm)
πΈ File::lchown β the "User Contributed Perl Documentation" era, bestie π
okay so picture this: you got a symlink, and you wanna change who owns it or when it was last touched, but you do NOT wanna mess with the actual file it's pointing at. that's literally the whole plot of this module. it lives in the File::lchown package and it's here to do exactly that. periodt. β¨
β¨ NAME β¨
File::lchown β modify attributes of symlinks without dereferencing them. that's it, that's the vibe. π¦
π SYNOPSIS π
use File::lchown qw( lchown lutimes );
lchown $uid, $gid, $linkpath or die "Cannot lchown() - $!";
lutimes $atime, $mtime, $linkpath or die "Cannot lutimes() - $!";
look at that. two functions. both of them refusing to follow your symlink. iconic behaviour fr fr. π
π DESCRIPTION π
so the regular chown system call is givingβ¦ extra. it dereferences your symlink and applies the ownership change to the file it points at instead. not the move. π
but some OSes are cool and provide system calls that don't dereference the symlink β they apply the changes straight to the named path, even when that path is a symlink. it's the same energy as lstat returning the attributes of the symlink itself rather than the file it points at. iykyk π
π FUNCTIONS π
π lchown
$count = lchown $uid, $gid, @paths;
sets the new user or group ownership on the paths you pass in, and it will not dereference any symlinks while doing it. no cap. π«Ά
pass -1 as either the $uid or the $gid and that specific attribute just stays exactly how it was β untouched, unbothered. π
returns the number of files that were successfully changed. simple as that.
π§ lutimes
$count = lutimes $atime, $mtime, @paths;
sets the access time and the modification time on the given paths, again without dereferencing any symlinks. slay. β¨
pass undef as both $atime and $mtime and it'll update the times to the current system time. easy. β
π okay real talk caveat time, bestie, listen up: for bothlchownandlutimesβ if you pass more than one path, and some later paths succeed after some earlier ones failed, then the value of$!is not reliable for telling you what actually went wrong. it's giving chaos. so if you care about using$!to report failures, only ever pass one path at a time. for real. π¨
since version 0.03, either time may be given as a fractional value, or as an ARRAY reference holding at least two elements. in that array case, element [0] should hold the integer seconds and element [1] the microseconds part β same style as Time::HiRes. πβ¨
π₯ SEE ALSO π₯
lchown(2)β change ownership of a filelutimes(2)β change file timestamps
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk>
and that's the whole page, queen. this manual came from the perl v5.42.3 distribution and it's dated 2026-08-19 β shoutout to the docs, they ate and left no crumbs. go lchown something without following it, you got this. πππ¦
π¦ where this page comes from
- ubuntu stonking: libfile-lchown-perl 0.03-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms