Sys::Utmp::Utent(3pm)

πŸ’– Sys::Utmp::Utent πŸ’–

okay so bestie, welcome to Sys::Utmp::Utent β€” it's the little Perl module (User Contributed Perl Documentation, no cap) that hands you one single utmp entry as a precious lil object. one entry. one vibe. let's get into it 🫢


✨ NAME ✨

Sys::Utmp::Utent β€” represent a single utmp entry. that's it, that's the whole job πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

  use Sys::Utmp;

  my $utmp = Sys::Utmp->new();

  while ( my $utent =  $utmp->getutent() )
  {
     if ( $utent->user_process )
     {
        print $utent->ut_user,"\n";
     }
   }

   $utmp->endutent;

🌸 DESCRIPTION 🌸

so like, the Sys::Utmp docs already told you that getutent returns an object of type Sys::Utmp::Utent β€” and this is that object, bestie. it's giving you methods for accessing the fields in the utmp record, and it also has methods for figuring out what type of record you're looking at. main character energy all around ✨

the access methods line up with the common names for the members of the C struct utent β€” and the ones provided here are the superset from the Gnu implementation, which means they might legitimately not exist on every system. and when they don't? no drama, they just return the empty string. okurrr πŸŽ€

πŸ“ ut_user

returns the user this record was created for β€” assuming it's a record for a user process. lowkey some systems might return other info depending on the record type, so don't be shocked. if no user was set, you get the empty string. and heads up: if tainting is switched on with the -T switch to perl, this value will be 'tainted', because it's genuinely possible the user name came from an untrusted source. πŸ”₯

πŸ“ ut_id

the identifier for this record. it might be the inittab tag, or honestly just some other system dependent value. iykyk πŸ’œ

πŸ“ ut_line

for user process records, this is the name of the terminal or line that the user is connected on πŸ–₯️✨

πŸ“ ut_pid

the process ID of the process that created this record. literally just the pid, periodt.

πŸ“ ut_type

the type of the record! it'll be a value matching one of these constants β€” though not all of them may be available on all systems, and there may well be others that get described in the getutent manpage or in /usr/include/utmp.h:

  • ACCOUNTING β€” record was created for system accounting purposes.
  • BOOT_TIME β€” the record was created at boot time.
  • DEAD_PROCESS β€” the process that created this record has terminated.
  • EMPTY β€” record probably contains no other useful information.
  • INIT_PROCESS β€” this is a record for a process created by init.
  • LOGIN_PROCESS β€” this record was created for a login process (e.g. getty).
  • NEW_TIME β€” record created when the system time has been set.
  • OLD_TIME β€” record recording the old time when the system time has been set.
  • RUN_LVL β€” records the time at which the current run level was started.
  • USER_PROCESS β€” record created for a user process (e.g. a login).

for convenience, Sys::Utmp::Utent also hands you lower case versions of the constant names as methods β€” they return true if the record is of that type. so cute, so handy πŸ’…

πŸ“ ut_host

on systems that support this, the method returns the hostname of the host for which the process that created the record was started β€” like, for example, a telnet login πŸ‘‘. and if taint checking has been turned on (with the -T switch to perl), then this value will be tainted, because it is possible that a remote user will be in control of the DNS for the machine they have logged in from. (see perlsec for more on tainting, bestie πŸ™ˆ)

πŸ“ ut_time

the time in epoch seconds at which the record was created ⏰


πŸ’€ BUGS πŸ’€

probably! 😭

this module has been tested on Linux, Solaris, FreeBSD, SCO Openserver and SCO UnixWare, and found to work on those platforms. so like, it's been around the block fr fr.

if you have difficulty building the module, or it doesn't behave as expected, then please contact the author β€” and include your /usr/include/utmp.h if that's appropriate. they want the receipts 🧾✨


🌈 AUTHOR 🌈

Jonathan Stowe, <jns@gellyfish.co.uk>


πŸ‘‘ LICENCE πŸ‘‘

this Software is Copyright Jonathan Stowe 2001-2013.

this Software is published as-is with no warranty express or implied. (say it with me: no warranty, periodt πŸ’…)

this is free software and can be distributed under the same terms as Perl itself. slay πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯

perl, Sys::Utmp


and that's the whole page, bestie!! this absolute icon of a manpage is from perl v5.42.3, dated 2026-08-19, and lives at Sys::Utmp::Utent(3pm) πŸ’–βœ¨πŸ¦‹ go read your utmp records, you gorgeous nerd, and drink some water 🫢🌸

πŸ“¦ where this page comes from