What is process accounting in Ubuntu
On Linux-based systems like Ubuntu, process accounting offers useful information to assist you in monitoring user activities. Process accounting is a way of keeping track of and summarizing processes and commands on a system. Ubuntu provides you the option to enable or disable the process accounting. Before enabling the process accounting on your Ubuntu system, understand this concept that process accounting is much different than the execution of the ps command. The “ps” command is used to print out the information related to the currently running process, including their PIDs. In contrast, process accounting displays the details of the completed commands, not the currently running ones. It has a single system file that stores more information than what is present inside the command history files.
Now we will show you how to enable process accounting in Ubuntu. Firstly, we need to install the “acct” utility on our system to follow the procedure. So let’s start!
How to install acct in Ubuntu
You can keep track of your processes by installing the “acct” utility in Ubuntu. It keeps track of user actions and permits you to see how long users have been connected to the system. This tool also provides a list of the commands and resources currently being used in the system. The “acct” utility runs in the system background; therefore, the system’s performance is unaffected.
To install acct on your Ubuntu system, write out this command in your terminal:
The error-free output declares that “acct” is successfully installed on your system. Now, enable the process accounting by utilizing the below-given command:
The output shows that process accounting is now enabled on your system, and it will save all of the data in the “var/log/account/pacct”:
How to view user connect time statistics in Ubuntu
In your Ubuntu terminal, execute the “ac” command to get the connection time statistics of the user. The “ac” command without any argument will let you know the hour-based connect time:
To know about connect time of all system users, utilize the “-p” option in your “ac” command:
On our system, we only have a “linuxhint” user; that’s why the output is only showing time statistics for this user:
You can view the log-in time statistics of a particular user. For this, you have to add the username to the “ac” command as follows:
To check out the daily log-in time statistics of a particular user, add the “-d” option in the previous command:
How to list account activity information in Ubuntu
The “sa” command summarizes the contents of the file containing the raw accounting data. If you want to list information of the commands executed by the users, then run the below-given command in your Ubuntu terminal:
In the other case, if you want to view the information of the users individually, then add the “-u” option in the “sa” command:
The “-m” option is added in the “sa” command to show the total number of user processes and their CPU time:
In the “sa” command, add the “-c” option to get the highest percentage of users:
The “lastcomm” command is used to display the list of last executed commands by the specified user:
How to disable process accounting in Ubuntu
If you want to disable process accounting, then you have to execute a below-given command in your terminal:
In Ubuntu, process accounting offers a lot of information about the processes that are functioning on your systems. It enables you to store the accounting records of both system and user activities, as well as the system resources used. The “acct” utility is used for enabling process accounting in Linux-based systems like Ubuntu. In this post, we have shared how to enable process accounting on your Ubuntu system. Moreover, we have also shown how to get the activity statistics in the terminal.