Users and Files: who is first
Files and Users
Starting to Understanding UNIX Programming
- Today we will write a version of the who utility.
- In the process, we will learn about files, users, time, and buffering.
How does who work?
- What does it do?
- How does it do it?
- How can we learn about the details?
How does who work?
- What does it do?
- Purpose: list users currently logged on
- Output: logname, terminal, time, from where
- We can see what it does by running the command.
- ... and by using the system manual pages.
How does who work?
- How does who do it?
- Where do we start?
- By reading the man page (and follow the "see also" links)
- Searching the manual pages for relevant keywords
- Perhaps reading relevant .h files in /usr/include
How does who work?
- Answer (for Solaris): calls library functions that
- open wtmp (or equivalent) file
- reads a record
- closes wtmp
- All who has to do is
- call library functions
- display information from structure provided
- Now we can write who.c