Miscellaneous of Linux Concepts

Source: Internet
Author: User
Tags exit in time and date

Login Record

/var/run/utmp,/var/log/wtmp
Wtmp and utmp files are binary files and they cannot be clipped or merged (using the Cat command) such as the tail command. Users need to use who, W, users, last, and AC to use the information contained in these two files.
Last command search wtmp to show users who have logged in since the first time the file was created
Lastlog command to see the last logon time for each user
Users print out a separate line for the currently logged-on user with a login session for each displayed user name
The W command queries the utmp file and displays information about each user in the current system and the process it is running
The WHO command queries the utmp file and reports each user who is currently logged on
The AC command reports the user's link time (in hours) based on login entry and exit in the current/var/log/wtmp file.

Ac-d the time to log on by day, ac-p calculate the logon time by user, ac-d LZB find the logon time for this user every day

A binary record containing the following structures is written to these two files:
struct UTMP {
Char Ut_line[8]; /* TTY line: "Ttyh0", "ttyd0", "ttyp0", ... * *
Char Ut_name[8]; /* Login Name */
Long Ut_time; /* seconds since Epoch * *
};
When logged in, the login program fills in such a structure and writes it to the Utmp file, and also adds it to the wtmp file.
When logging off, the INIT process erases the corresponding records in the Utmp file (each byte is filled with 0) and adds a new record to the Wtmp file. Read the logout record in the Wtmp file, and its Ut_name field is cleared to 0. Special record entries are added to the Wtmp file when the system restarts, and before and after changes to the system time and date. The WHO (1) program reads the Utmp file and prints its contents in a readable format. Later versions of Unix provide the last (1) command, which reads the wtmp file and prints the selected record. The Wtmp file, which tracks individual logon and logoff events.
wted
Wtmp/utmp Log editing program. You can use this tool to edit all wtmp or utmp types of files.
Z2
Utmp/wtmp/lastlog Log Cleanup Tool. You can delete all entries for a user name in the Utmp/wtmp/lastlog log file. However, if the Linux system needs to manually modify its source code, set the location of the log file.

File creation Time

Several file-related time:
1, Access time, read the contents of this file, this time will be updated. For example, use the more command for this file. The LS, stat command does not modify the file access time.
2, modify the time, modify the contents of the file once, this time will be updated. For example: VI after saving files. The time that ls-l lists is this time.
3, state change time. Change the file properties once with the chmod command, and the time will be updated. To view the detailed status of the file, the exact modification time, etc., you can use the stat command file name.
Stat temp.c

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.