Re: Additional NFS exports? = Re: Additions on /etc/kde3/kdm/Xstartup
On Sat, 27 Nov 2004, Ralf Gesel|ensetter wrote:
> Am Mittwoch, 24. November 2004 00:06 schrieb Petter Reinholdtsen:
> > This is not needed. The last log (wtmp) will include info about the
> > user sessions. Run 'last' to get the list.
> Hi, thank you! I didn't know that tool - where is this information
> actually stored?
The answer is (on Debian systems at least) /var/log/wtmp which is not a
human readable file. This is documented in the man page.
If it weren't documented, how might you find out? The strace tool is used
to "trace system calls and signals", which includes opening and closing
files among other things. If you run a program with strace, it'll output a
list of every system call and signal used.
So if you run:
strace last gavin 2>strace.out
the command 'last gavin' is executed and a trace of system calls is output
to standard error which for convenience we redirect (using the 2> syntax)
to the file strace.out. Among a rather large amount of other system data
you'll see a few "open" statements, one for each time a file is opened.
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
open("/var/log/wtmp", O_RDONLY) = 3
open("/etc/localtime", O_RDONLY) = 4
Clearly the storage file has to be opened so it must be one of the above
files. Admittedly it might not be totally obvious to a beginner which one,
but at least the list is relatively short on this occasion :-)
If you ever find yourself wondering things like "Is program X actually
reading file Y or just ignoring it?" or "in what order does program Z read
it's 5 config files?" strace can be very handy.