Psacct - log all the linux users activty

I have psacct up and running (tried it today for the first time) and created a separate directory under /var/log with the name shelllogs and whenever user does anything a log file is created under /var/log/shelllogs with their respective name as below.

“root-as-kachwa-2021-12-03-09:26:23_console.log”

But every time when I switch to another user from root or from normal user to root I see output being displayed on the terminal and moreover I want to send logs to a remote host, any suggestions, below is the script.

cat /etc/profile.d/history.sh
export HISTSIZE=10000
export HISTTIMEFORMAT=’%F %T ’
export HISTFILE=/var/log/shelllogs/$(who am i | awk ‘{print $1}’;exit)-as-$(whoami)-$(date +%F-%T) > /dev/null 2>&1
export PROMPT_COMMAND=‘history -a’

What do you mean you see the output on terminal? Can you provide us a little more information?

Monk, whenever linux user switches to another user or exits from another user terminal he sees the output on the terminal which says “your logs are saved in so and son location with the file name”, please see below,also we want these log files to be logged in to some remote server and not locally.

[root@server ~]# exit
exit
Script done, file is /var/log/shelllogs/opc-as-root-2021-12-04-06:47:22_console.log
[root@server ~]# sudo su -
Last login: Sat Dec 4 06:47:22 GMT 2021 on pts/0
Script started, file is /var/log/shelllogs/opc-as-root-2021-12-04-06:47:31_console.log
[root@server ~]# sudo su - kachwa
Last login: Fri Dec 3 09:26:23 GMT 2021 on pts/2
Script started, file is /var/log/shelllogs/root-as-kachwa-2021-12-04-06:47:41_console.log
[kachwa@server ~]$ touch three
[kachwa@server ~]$ exit
exit
Script done, file is /var/log/shelllogs/root-as-kachwa-2021-12-04-06:47:41_console.log

Are you trying the lastcomm command? It show me information about previously executed commands. Like I say:

lastcomm {user-name}
lastcomm {command-name}
lastcomm --user {user-name-to-audit} {command-name}

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki