How to enable process accounting in Ubuntu

As Linux administrators, one of our everyday jobs is managing and monitoring each user’s activities within an organizational infrastructure. It is also beneficial to gather data from the system and network. For instance, at our company, we have a developers team that is constantly working on servers. As a result, we will need the best utility to keep an eye on them. Isn’t it?

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:

$ sudo apt-get install acct

The error-free output declares that “acct” is successfully installed on your system. Now, enable the process accounting by utilizing the below-given command:

$ sudo /usr/sbin/accton on

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:

The “-d” option is added in the “ac” command to view the daily log in hour-based time:

$ ac -d

To know about connect time of all system users, utilize the “-p” option in your “ac” command:

$ ac -p

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:

$ ac linuxhint

To check out the daily log-in time statistics of a particular user, add the “-d” option in the previous command:

$ ac -d linuxhint

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:

$ sudo sa

In the other case, if you want to view the information of the users individually, then add the “-u” option in the “sa” command:

$ sa -u

The “-m” option is added in the “sa” command to show the total number of user processes and their CPU time:

$ sa -m

In the “sa” command, add the “-c” option to get the highest percentage of users:

$ sa -c

The “lastcomm” command is used to display the list of last executed commands by the specified user:

$ lastcomm root

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:

$ sudo /usr/sbin/accton off


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.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.