Cyberithub

10 Easy Steps to Install psacct or acct User Activity Monitoring tool on RHEL/CentOS 7/8

In this article, I will take your through 10 Easy Steps to Install psacct User Activity Monitoring tools on RHEL/CentOS 7/8. Now a days there are many open source user activity monitoring tool available to monitor the user activity on Linux based Servers. psacct or acct are also one such package that provides multiple number of tools with various options to monitor the User activity. psacct package is available for RHEL/CentOS based Servers whereas acct package is available for Ubuntu/Debian Based Servers. Here we will focus on the installation and usage of psacct package in detail with examples.

10 Easy Steps to Install psacct or acct User Activity Monitoring tool on RHEL/CentOS 7/8

Steps to Install psacct User Activity Monitoring Tool on RHEL/CentOS 7/8

Also Read: How to Install PIP3 Utility on Linux(RHEL/CentOS 7/8){Easy Steps}

Step 1: Prerequisites

a) You need to have a running RHEL/CentOS 7/8 System.

b) You should have yum tool installed in your Server. You can check Top 22 YUM command examples in RedHat/CentOS 7 to know more about yum command.

c) You need to have root or sudo access to run privileged commands. Please Check How to Add User to Sudoers to know more about providing sudo access to the User.

Step 2: Update your Server

Before going through the steps to install psacct User activity monitoring tool on RHEL/CentOS 7/8 based Server you need to first update your server using yum -y update command as shown below. This will download and install all the latest updates from yum repository.

[root@localhost ~]# yum -y update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* epel: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.18.0-5.el7_7.1 will be updated
---> Package NetworkManager.x86_64 1:1.18.0-5.el7_7.2 will be an update
---> Package NetworkManager-libnm.x86_64 1:1.18.0-5.el7_7.1 will be updated
---> Package NetworkManager-libnm.x86_64 1:1.18.0-5.el7_7.2 will be an update
---> Package NetworkManager-team.x86_64 1:1.18.0-5.el7_7.1 will be updated
---> Package NetworkManager-team.x86_64 1:1.18.0-5.el7_7.2 will be an update
---> Package NetworkManager-tui.x86_64 1:1.18.0-5.el7_7.1 will be updated
---> Package NetworkManager-tui.x86_64 1:1.18.0-5.el7_7.2 will be an update
---> Package binutils.x86_64 0:2.27-41.base.el7_7.1 will be updated
---> Package binutils.x86_64 0:2.27-41.base.el7_7.3 will be an update
---> Package curl.x86_64 0:7.29.0-54.el7_7.1 install psacct will be updated
---> Package curl.x86_64 0:7.29.0-54.el7_7.2 will be an update
---> Package docker.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be updated
---> Package docker.x86_64 2:1.13.1-109.gitcccb291.el7.centos will be an update
---> Package docker-client.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be updated
---> Package docker-client.x86_64 2:1.13.1-109.gitcccb291.el7.centos will be an update
---> Package docker-common.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be updated
---> Package docker-common.x86_64 2:1.13.1-109.gitcccb291.el7.centos will be an update
---> Package epel-release.noarch 0:7-11 will be updated

Step 3: Install psacct tool

Next step is to install psacct user monitoring tool by using yum install -y psacct command as shown below.

[root@localhost ~]# yum install -y psacct
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 7.4 kB 00:00:00
* base: mirrors.piconets.webwerks.in
* epel: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
base | 3.6 kB 00:00:00
download.mono-project.com_repo_centos_ | 2.9 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
kubernetes/signature | 454 B 00:00:00
kubernetes/signature | 1.4 kB 00:00:00 !!!
nodesource | 2.5 kB 00:00:00
puppetlabs-pc1 | 2.5 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:01
(2/2): epel/x86_64/primary_db | 6.8 MB 00:00:04
Resolving Dependencies
--> Running transaction check
---> Package psacct.x86_64 0:6.6.1-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
psacct x86_64 6.6.1-13.el7 base 93 k

Transaction Summary
========================================================================================================================================================================
Install 1 Package

Total download size: 93 k
Installed size: 199 k
Downloading packages:
psacct-6.6.1-13.el7.x86_64.rpm | 93 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : psacct-6.6.1-13.el7.x86_64 1/1
Verifying : psacct-6.6.1-13.el7.x86_64 1/1

Installed:
psacct.x86_64 0:6.6.1-13.el7

Complete!

Step 4: Check and Start psacct Service

If you check psacct service immediately after installation using service psacct status command then it will show in inactive state as you can see below.

[root@localhost ~]# service psacct status
Redirecting to /bin/systemctl status psacct.service
● psacct.service - Kernel process accounting
Loaded: loaded (/usr/lib/systemd/system/psacct.service; disabled; vendor preset: disabled)
Active: inactive (dead)

You need to start the service by using service psacct start command.

[root@localhost ~]# service psacct start
Redirecting to /bin/systemctl start psacct.service

Now if you again the psacct service status using service psacct status command then it will show in active and running state as shown below.

[root@localhost ~]# service psacct status
Redirecting to /bin/systemctl status psacct.service
● psacct.service - Kernel process accounting
Loaded: loaded (/usr/lib/systemd/system/psacct.service; disabled; vendor preset: disabled)
Active: active (exited) since Sun 2020-04-05 09:21:10 EST; 5s ago
Process: 24115 ExecStart=/usr/sbin/accton /var/account/pacct (code=exited, status=0/SUCCESS)
Process: 24112 ExecStartPre=/usr/libexec/psacct/accton-create (code=exited, status=0/SUCCESS)
Main PID: 24115 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/psacct.service

Apr 05 09:21:10 localhost systemd[1]: Starting Kernel process accounting...
Apr 05 09:21:10 localhost accton[24115]: Turning on process accounting, file set to '/var/account/pacct'.
Apr 05 09:21:10 localhost systemd[1]: Started Kernel process accounting.

Step 5: Verify the Package Installation

If you want to verify the psacct package installation in RPM DB then you need to use rpm -qa | grep -i psacct command as shown below.

[root@localhost ~]# rpm -qa | grep -i psacct
psacct-6.6.1-13.el7.x86_64

Step 6: Enable psacct service 

If you want psacct service to be enabled on Run Level 1 and 3 then you need to use chkconfig --level 13 psacct on command as shown below. You can also use systemctl enable psacct command to enable the service at the boot time.

[root@localhost ~]# chkconfig --level 13 psacct on
Note: Forwarding request to 'systemctl enable psacct.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/psacct.service to /usr/lib/systemd/system/psacct.service.

Step 7: Check ac and sa version

If you want to check the ac command version then you need to use ac -V command as shown below. As you can see from below output current ac command version is 6.6.1

[root@localhost ~]# ac -V
ac: GNU Accounting Utilities (release 6.6.1)

If you want to check the sa command version then you need to use sa -V command as shown below. As you can see from below output current sa command version is 6.6.1.

[root@localhost ~]# sa -V
sa: GNU Accounting Utilities (release 6.6.1)

Step 8: Using ac User monitoring tools

If you want to print the total hours for each user then you need to use ac -p command as shown below.

[root@localhost ~]# ac -p
root  3460.19
total 3460.19

p : Print time totals for each user in addition to the usual everything-lumped-into-one value. More on ac command Man Page.

Step 9: Check Package details of ac and sa utility

If you want to check the package details of ac utility then you need to first find the complete path of ac utility using which ac command as shown below.

[root@localhost ~]# which ac
/usr/bin/ac

Then you need to query the RPMDB for package details using rpm -qf /usr/bin/ac command.

[root@localhost ~]# rpm -qf /usr/bin/ac
psacct-6.6.1-13.el7.x86_64

Similarly, for sa utility also you need to first query the command path using which sa command.

[root@localhost ~]# which sa
/usr/sbin/sa

Then you need to query the RPMDB using rpm -qf /usr/sbin/sa command to know about the package details.

[root@localhost ~]# rpm -qf /usr/sbin/sa
psacct-6.6.1-13.el7.x86_64

Step 10: Remove psacct package from Server

If you want to remove psacct package from your Server then you need to use yum remove psacct -y command as shown below.

[root@localhost ~]# yum remove psacct -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package psacct.x86_64 0:6.6.1-13.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Removing:
psacct x86_64 6.6.1-13.el7 @base 199 k

Transaction Summary
========================================================================================================================================================================
Remove 1 Package

Installed size: 199 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : psacct-6.6.1-13.el7.x86_64 1/1
Verifying : psacct-6.6.1-13.el7.x86_64 1/1

Removed:
psacct.x86_64 0:6.6.1-13.el7

Complete!

 

 

 

Popular Recommendations:-

Solved: ModuleNotFoundError: No module named ‘requests’ in Python 3

How to Properly Search PHP Modules Using YUM tool in Linux(RHEL/CentOS 7/8)

Solved: FATAL: Authentication Helper Program /usr/lib/squid/basic_ncsa_auth: (2) No Such File or Directory

How to Install and Configure Squid Proxy Server on RHEL/CentOS 7/8

Primitive Data Types in Java – int, char, byte, short, long, float, double and boolean

5 Best Ways to Become root user or Superuser in Linux (RHEL/CentOS/Ubuntu)

11 Best Python OS Module Examples on Linux

How to Install MariaDB 5.5 Server on RHEL/CentOS 7 Linux with Easy Steps

Leave a Comment