LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-22-2018, 03:38 AM   #1
wolodyj
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Rep: Reputation: Disabled
User command duration


Hi

I am looking for a tool that saves the duration of user commands in the log.

Thanks in advance
W
 
Old 08-22-2018, 04:15 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,717

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
history ?
 
Old 08-22-2018, 04:39 AM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,241

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
You can set log levels - how much is logged. Try 'man syslogd'
 
Old 08-22-2018, 04:39 AM   #4
lougavulin
Member
 
Registered: Jul 2018
Distribution: Slackware,x86_64,current
Posts: 279

Rep: Reputation: 100Reputation: 100
You mean for every commands used ? All the time ?

For one command, there is :
Code:
time command args
Otherwise, for all commands, I guess you would have to save the output every N minutes/seconds :
Code:
top -U $USER -n 1 -S
 
Old 08-22-2018, 06:10 AM   #5
wolodyj
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks .

But I am looking for a tool like auditd that will write to the log the durations of the commands of all system users.
 
Old 08-22-2018, 06:16 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,573

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Best write that log to a partition with nothing critical on it, and make it a big one. That log could grow VARY large VERY fast.

Why would you consider such a log useful?
 
Old 08-22-2018, 06:18 AM   #7
wolodyj
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
I have such a requirement from the client
 
Old 08-22-2018, 06:49 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,779

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
looks like you are looking for something - probably a bottleneck, but this is not the best approach.
I would recommend you to try to solve the original problem, because this one is more or less impossible and the result will be useless. But if you wish:
which users should be logged exactly? Which actions/conmmands are important? What are the exact details you need? What format is required?
 
1 members found this post helpful.
Old 08-22-2018, 07:23 AM   #9
wolodyj
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
My client needs a tool that he writes in the log:
1. date and time of the command execution
2. who command execution
3 command
4 Has command ended with success ?
5 User command duration

1-4 i used tool auditd

5. ???
 
Old 08-22-2018, 09:27 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,604

Rep: Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960Reputation: 7960
Quote:
Originally Posted by wolodyj View Post
My client needs a tool that he writes in the log:
1. date and time of the command execution
2. who command execution
3 command
4 Has command ended with success ?
5 User command duration

1-4 i used tool auditd

5. ???
As others have said, this is going to be a fairly large bottleneck on your system. Because you'd have to preface EVERY COMMAND (assuming this is through the CLI only; GUI would be next to impossible) with some sort of script that would note the time of start and end. For every command...and every user. You can preface every command with the 'time' built-in function, but that returns it to the screen. If you want to capture all of this, you'll have to do some scripting and put this in place (somehow).

Since this is for your client, who is paying you...how much do we get for solving this problem?
 
Old 08-22-2018, 05:04 PM   #11
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,573

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
I might solve this by downloading the source for the BASH shell and creating a new shell with my patches: to create a new format for command execution lines, perhaps modified history, that would optionally log the required information. If you then make that new shell the default for those users you need to monitor....

How good is your C coding?

Last edited by wpeckham; 08-22-2018 at 05:05 PM.
 
Old 08-22-2018, 05:28 PM   #12
lougavulin
Member
 
Registered: Jul 2018
Distribution: Slackware,x86_64,current
Posts: 279

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by wpeckham View Post
I might solve this by downloading the source for the BASH shell and creating a new shell with my patches: to create a new format for command execution lines, perhaps modified history, that would optionally log the required information. If you then make that new shell the default for those users you need to monitor....
This one interesting way.
Seems more effective than coding a demon looking at process at first. But unfortunately, all process and commands are not launched within a shell session...
 
Old 08-23-2018, 03:18 AM   #13
wolodyj
LQ Newbie
 
Registered: Aug 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for help

i will use sysdig
 
Old 08-23-2018, 03:23 AM   #14
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,779

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
looks like sysdig can only monitor docker. Is this what you need?
 
Old 08-23-2018, 03:38 AM   #15
lougavulin
Member
 
Registered: Jul 2018
Distribution: Slackware,x86_64,current
Posts: 279

Rep: Reputation: 100Reputation: 100
Thanks to let us know.
I did not know sysdig, so I took a quick look and I guess you are going to use the "spy user" function (-c).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Time duration from one command to another niharikaananth Linux - Newbie 3 08-08-2011 04:40 AM
RHCE exam duration vedaprasad Linux - Newbie 1 03-12-2010 05:18 PM
[SOLVED] Getting duration of execution in bash Himilhil Linux - Software 4 11-04-2009 02:21 AM
are duration of rhce courses is enough? Barq Linux - Certification 1 02-06-2008 07:04 AM
Duration of backscatter billymayday Linux - Security 9 01-20-2007 05:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration