AliasFile(3pm)
π AliasFile β the Unix::AliasFile page, but make it cute π
okay bestie, gather round, because this is AliasFile(3pm) from the User Contributed Perl Documentation and it's literally the glow-up your /etc/aliases file has been waiting for. she's a Perl module. she's iconic. let's go β¨
πΈ NAME πΈ
Unix::AliasFile β a whole Perl interface to /etc/aliases format files. yes, that format. the one with the colons. she handles it for you π«Ά
π SYNOPSIS π
no thoughts, just vibes, and also this exact code:
use Unix::AliasFile;
$al = new Unix::AliasFile "/etc/aliases";
$al->alias("bozos", @members);
$al->delete("deadlist");
$al->remove_user("coolmail", "bgates", "badguy");
$al->add_user("coolmail", "joecool", "goodguy");
$al->remove_user("*", "deadguy");
$al->commit();
undef $al;
look at her. main character energy fr fr π
π¦ DESCRIPTION π¦
so the Unix::AliasFile module is an abstract interface to Unix alias files. it does the annoying stuff so you don't have to: file locking, putting colons and commas in exactly the right spots, and honestly just all the other niggling little details that make you want to scream into a pillow π
here's the part that lowkey slaps: unlike some of the other Unix::*File modules, this one preserves the order of your alias file. with a few exceptions, obviously. comments and aliases show up in the file in the same order they started in. the one exception era is if you've got comment lines sprinkled between the beginning of an alias and the continuation lines for that same alias β in that case, those comments will show up after the alias that contains them. not a bug, just the way she moves β¨
π METHODS π
π« add_user( ALIAS, @USERS )
adds the list of users to an alias that already exists. users who are already in that alias? silently ignored, no drama, no note. the special alias name * will add the users to every single alias. returns 1 on success or 0 on failure.
π« alias( ALIAS [,@USERS] )
the multitasker. this one can add, modify, or return info about an alias. give it just one alias parameter and it hands you back a list of that alias's members β or undef if no such alias exists. give it more parameters and the named alias gets created (or modified, if it was already there), and the member list gets returned to you in that case too. queen of versatility π
π« aliases( )
returns a list of all existing aliases, sorted alphabetically. in scalar context? she returns the total number of aliases instead. slay.
π« comment( ALIAS, COMMENT )
inserts a comment line before the specified alias. you have to bring your own comment marker (#), but a newline gets appended automatically unless your comment already has one. returns 1 on success and 0 on failure.
π« commit( [BACKUPEXT] )
go read the Unix::ConfigFile documentation for the description of this method, bestie. iykyk π«Ά
π« delempty( )
deletes every existing alias that has no members. returns a count of how many aliases got deleted. bye felicia π
π« delete( ALIAS )
deletes the named alias. if the alias you supplied doesn't exist? no effect. she simply does not care.
π« new( FILENAME [,OPTIONS] )
again, go check the Unix::ConfigFile documentation for this one. same energy.
π« remove_user( ALIAS, @USERS )
removes the list of users from an existing alias. users who aren't members of that alias are silently ignored. the special alias name * will remove the users from every alias. returns 1 on success or 0 on failure.
π« rename_user( OLDNAME, NEWNAME )
changes one username to another across every alias. returns the number of aliases that were affected. glow-up for your users β¨
π« uncomment( COMMENT )
removes the comment from the file that matches the text you supply. the match must be exact. no fuzzy vibes allowed. returns 1 on success and 0 on failure.
π BUGS π
okay so, real talk. Unix::AliasFile will work with Perl versions before 5.005, but it might throw a minor bug under those versions. the bug makes program aliases with embedded comma characters get broken apart. π¬
this does not happen under 5.005 and up, because of the use of the Text::ParseWords module, which changed significantly with the 5.005 release. so like, upgrade. fr fr.
π AUTHOR π
Steve Snodgrass, ssnodgra@fore.com β thank you for your service, king π«Ά
π SEE ALSO π
Unix::AutomountFileUnix::ConfigFileUnix::GroupFileUnix::PasswdFile
go read those too, bestie, they're all in the same friend group π
and that's the whole page, babe β this was perl v5.32.1, dated 2021-08-21, and that's the AliasFile(3pm) footer, mwah π stay locked, stay parsed, stay iconic πΈβ¨
π¦ where this page comes from
- debian bookworm: libunix-configfile-perl 0.6-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libunix-configfile-perl 0.6-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libunix-configfile-perl 0.6-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libunix-configfile-perl 0.6-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libunix-configfile-perl 0.6-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libunix-configfile-perl 0.6-3 Β· 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