Search This Blog

Thursday, May 28, 2009

Linux command similar to history, list last used commands.

Linux command similar to history, list last used commands.

accton, lastcomm - accouting on and last command. This is
a way to monitor users on your system. As root, you
would implement this as follows:

$ accton -h
Usage: accton [-hV] [file]
[--help] [--version]

The system's default process accounting file is /var/account/pacct.

Note the default file location is /var/account/pacct so we'll turn
it on system wide with the following command.

$ accton /var/account/pacct

Now take a look at this file. It will grow. To see command that
are executed, use the lastcomm command.

$ lastcomm

The above command gives output for all users. To get the data
for user "chirico" execute the following command:

$ lastcomm --user chirico

You can also get a summary of commands with sa.

[chirico@big ~]$ sa
30 5.23re 0.00cp 10185k
11 4.83re 0.00cp 8961k ***other
8 0.13re 0.00cp 19744k nagios*
4 0.00re 0.00cp 2542k automount*
3 0.00re 0.00cp 680k sa
2 0.13re 0.00cp 17424k check_ping
2 0.13re 0.00cp 978k ping

To turn off accounting, execute accton without a filename.

$ accton

No comments:

Post a Comment