Skip to content

nixCraft

Linux Tips, Hacks, Tutorials, And Ideas In Blog Format

  • About
  • Howtos and tutorials
  • Linux Shell Scripting Tutorial
  • RSS/FEED
  • DONATIONS
Search

nixCraft

Linux Tips, Hacks, Tutorials, And Ideas In Blog Format

nixCraft

Tag: utmp header file

When a user logs in what files are updated in UNIX / Linux

in Categories Linux, Linux login control, RedHat/Fedora Linux, UNIX last updated October 2, 2007

One of our regular reader asks:

I’d like to discover information about who is currently using the system. When a user logs in what files are updated in UNIX / Linux?

Linux / UNIX have utmp and wtmp files to keep login records. Following three files keeps track of all logins and logouts to the system.

=> /var/run/utmp : List of current login sessions.
=> /var/log/wtmp : Database of past user logins / previous login sessions.
=> /var/log/lastlog : Last logins information about users

How do I access login records files?

These are a binary log files, and grows linearly at its end. So you cannot view records using cat or other text based utilities. The file <utmp.h> declares the structures used to record information about current users in the file. This can be accessed using C programs or other specialized utilities:

  • The utmp file is used and accessed by the following commands:
    • users command to print the user names of users currently logged in to the current host
    • w command to display who is logged in and what they are doing
    • who command to find out who is logged in
  • The wtmp file is used and accessed by the following command:
    • last command to find system last reboot date and time
    • ac command to keep a detailed audit trail of what’s being done on your Linux systems

Suggested readings:

  • Man pages – ac(1), date(1), last(1), login(1), who(1), getutent(3), updwtmp(3), init(8), wtmp(5)
  • Header file /usr/include/utmp.h
4 Comments

Featured Articles:

  • 30 Cool Open Source Software I Discovered in 2013
  • 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
  • Top 30 Nmap Command Examples For Sys/Network Admins
  • 25 PHP Security Best Practices For Sys Admins
  • 20 Linux System Monitoring Tools Every SysAdmin Should Know
  • 20 Linux Server Hardening Security Tips
  • Linux: 20 Iptables Examples For New SysAdmins
  • Top 20 OpenSSH Server Best Security Practices
  • Top 20 Nginx WebServer Best Security Practices
  • 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
  • 15 Greatest Open Source Terminal Applications Of 2012
  • My 10 UNIX Command Line Mistakes
  • Top 10 Open Source Web-Based Project Management Software
  • Top 5 Email Client For Linux, Mac OS X, and Windows Users
  • The Novice Guide To Buying A Linux Laptop

Sign up for my newsletter

Sign up for my newsletter

Follow us

TwitterFacebookGoogle+



RSS Recently updated

  • How To Use Bash Parameter Substitution Like A Pro
  • How To Run Multiple SSH Command On Remote Machine And Exit Safely
  • Delete all root mail / inbox on Linux / Unix from a shell prompt
  • How to use lftp to accelerate ftp/https download speed on Linux/UNIX
  • How To Recover Linux Grub Boot Loader Password
  • OpenBSD install or add binary software package using pkg_add
  • How to use yum-cron to automatically update RHEL/CentOS Linux
  • Download Tux Paint Program For Young Children (Linux/macOS/Windows)
  • Linux Find Out Last System Reboot Time and Date Command
  • Linux wget: Your Ultimate Command Line Downloader
nixCraft @2000-2018 nixCraft. All rights reserved.
  • PRIVACY
  • TERM OF SERVICE
  • CONTACT/EMAIL
  • DONATIONS
Hosted by Linode
DNS & CDN by Cloudflare
Designed and Developed by Prospect One