Whereas not a really well-known Linux command, ac can present very helpful stats on consumer login time. In its easiest kind, it’ll present you ways a lot time customers have spent on the system within the time interval coated by the wtmp file. All you must kind is “ac” to get a determine displaying total login time for all customers.
$ ac complete 8360.60
The determine above signifies that customers spent a complete of 8,360.6 hours on the system. Wanting on the wtmp file with the who command, we are able to see that the saved logins began on June sixth – just a little greater than 6 months earlier.
$ who /var/log/wtmp | head -2 shs tty2 2022-06-06 16:00 (tty2) shs pts/1 2022-06-06 16:23 (192.168.0.12)
To take a look at the instances by consumer, add the -p (individuals) argument.
$ ac -p popeye 1081.10 nemo 2301.70 shark 801.00 shs 4176.80 complete 8360.6
To take a look at each day login totals, you need to use the ac -d (day) command. Add a grep command in the event you solely wish to see login instances for one month.
$ ac -d | grep Oct | head -11 Oct 1 complete 46.21 Oct 2 complete 55.09 Oct 3 complete 34.50 Oct 4 complete 69.48 Oct 5 complete 50.73 Oct 6 complete 44.85 Oct 7 complete 25.05 Oct 8 complete 74.49 Oct 9 complete 44.88 Oct 10 complete 34.28 Oct 11 complete 38.36
Piping the output of the ac -d command to the head command is one other option to see how far again the wtmp file goes.
$ ac -d | head -1 Jun 6 complete 82.92
You can too pipe the ac output to the tail command to see the newest days. This offers the present day in addition to earlier days within the month.
$ ac -d | tail -10 Nov 1 complete 121.79 Nov 2 complete 24.86 Nov 3 complete 25.75 Nov 4 complete 24.63 Nov 5 complete 25.03 Nov 7 complete 52.97 Nov 8 complete 26.86 Nov 9 complete 27.66 Nov 10 complete 24.56 In the present day complete 14.91
If in case you have wtmp knowledge from another time interval or system saved in a file, you possibly can run an ac command in opposition to that file like this:
$ ac -f /var/log/Jupiter complete 5434.7
The ac -h (assist) command will present a abstract of the command’s many choices.
$ ac -h Utilization: ac [OPTION] ... OPTIONS: -d, --daily-totals Print totals for every day -p, --individual-totals Print time totals for every consumer -f, --file <file> Learn from <file> --complain Print errors for no matter drawback --reboots Depend the time between login and reboot --supplants Depend the time between logins on the terminal --timewarps Depend the time between login and time warp --compatibility Shortcut for --reboots --supplants --timewarps -a, --all-days Don't skip days with out login exercise --tw-leniency <worth> Set the time warp leniency <worth> in seconds --tw-suspicious <worth> Set the time warp suspicious <worth> in seconds --print-year Print yr when displaying dates --print-zeros Do not suppress zeros in class totals --debug Print verbose inside data -V, --version Present model and exit -h, --help Present assist and exit
The system’s default login accounting file is /var/log/wtmp. Whereas the ac command’s summaries are typically extra helpful, you possibly can view each entry in that file in the event you see the necessity. Use the who /var/log/wtmp command as proven under. Piping its output to the extra command will assist you to slowly transfer by means of the small print and get a really feel for a way a lot and the way typically the actual system is getting used.
$ who /var/log/wtmp | extra shs pts/1 2022-06-07 06:40 (192.168.0.6) shs pts/2 2022-06-07 08:26 (192.168.0.12) shark pts/3 2022-06-07 09:00 (192.168.0.12) nemo pts/2 2022-06-07 10:09 (192.168.0.11) nemo pts/2 2022-06-07 11:05 (192.168.0.11) nemo pts/2 2022-06-07 12:12 (192.168.0.6) shs pts/2 2022-06-07 13:50 (192.168.0.12) nemo pts/2 2022-06-07 14:15 (192.168.0.11) shs pts/1 2022-06-06 16:23 (192.168.0.12) shs tty2 2022-06-06 16:00 (tty2) shs pts/1 2022-06-06 17:32 (192.168.0.12) shs tty2 2022-06-06 17:17 (tty2) shs tty2 2022-06-06 17:21 (tty2) shs pts/1 2022-06-06 18:35 (192.168.0.6) shark pts/2 2022-06-07 18:26 (192.168.0.6)
Wrap-up
The ac command makes data saved within the wtmp file extra accessible. If you wish to know the way a lot time customers spend logged right into a system or how typically they log in, it’s simply what you want. Probably standing for “accounting”, the ac command means that you can view knowledge within the wtmp file in a number of very helpful methods.
Copyright © 2022 IDG Communications, Inc.