LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2010, 03:11 PM   #1
kabugima2
LQ Newbie
 
Registered: Oct 2009
Posts: 10

Rep: Reputation: 0
Linux Admistration


Which commands do you use to output the current users logged into the system and accessing a specific file?
 
Old 04-27-2010, 03:22 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
who
this command will list all users logged in on your system.

ps aux | grep <username>
this will list all process by the username you supply
 
1 members found this post helpful.
Old 04-27-2010, 03:47 PM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
This command (lsof | grep <filename> | cut -c 21-27 | sort -u) will do it. Example
Code:
$ lsof | grep /tmp | cut -c 21-27 | sort -u
Peter
You might want to look at info lsof to see what other information is available.

Last edited by PTrenholme; 04-27-2010 at 03:50 PM.
 
1 members found this post helpful.
Old 04-28-2010, 12:14 PM   #4
kabugima2
LQ Newbie
 
Registered: Oct 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Adminstrative

suppose you want to write a shell-script that outputs a periodic listing of owners of files that are active at given times during the day, so as to monitor who was logged in when some particular event occurred e.g when someone changed the contents of files, how would you achieve this ? please help!
 
Old 04-28-2010, 01:03 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,886

Rep: Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258
Quote:
Originally Posted by kabugima2 View Post
suppose you want to write a shell-script that outputs a periodic listing of owners of files that are active at given times during the day, so as to monitor who was logged in when some particular event occurred e.g when someone changed the contents of files, how would you achieve this ? please help!
I'd use cron to run it (or make the script sleep a certain time, then loop through), and a combination of who and lsof to do the task. I'd probably have a list of files I wanted monitored, either as a text file, or hard-coded in the script, so the lsof would just check those files, or grep for it.
 
Old 04-28-2010, 02:00 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I have merged your two closely-related threads. Please keep one thread per topic---thanks
 
  


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
Linux Training Tips - Boot Linux from a Linux Installation CD or a Linux Live CD to L beibei Linux - General 1 10-29-2009 04:25 AM
Which Distribution Package is best for development + learning system admistration+..? thandermax Linux - Newbie 11 07-02-2005 03:50 AM


All times are GMT -5. The time now is 02:33 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration