LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
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,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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: 26,661

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
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: Mint
Posts: 17,809

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:14 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
Open Source Consulting | Domain Registration