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 12-03-2012, 06:03 AM   #1
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Rep: Reputation: 24
How to know the number of files opened by a specific user.


Hi LQ folks,


I'd like to know a single line command to count the number of opened files by a specific user.

It is ok to pipe the command output to wc -l.

Well, i tried to do it:

Quote:
sudo -u oracle lsof|wc -l
please let me know..will this work(as i need to know the open file count of oracle)?

Please gimme some info. if needed .. i'm confused between no. of opened files & file descriptors.


Thanks,
Ravi
 
Old 12-03-2012, 06:39 AM   #2
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,572
Blog Entries: 1

Rep: Reputation: Disabled
Code:
sudo lsof -u oracle |wc -l
 
Old 12-03-2012, 06:47 AM   #3
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Original Poster
Rep: Reputation: 24
Thanks Habitual
 
Old 12-03-2012, 07:28 AM   #4
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Original Poster
Rep: Reputation: 24
Can any one say me the difference between the following commands:

====>
Quote:
sudo -u oracle lsof|wc -l
&

====>
Quote:
sudo lsof -u oracle|wc -l

As i can see the difference in the outputs of the above commands.


Thanks,
Ravi

Last edited by RaviTezu; 12-03-2012 at 07:34 AM.
 
Old 12-03-2012, 07:37 AM   #5
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 845
Blog Entries: 2

Rep: Reputation: 212Reputation: 212Reputation: 212
Do you mean the arguments "-u oracle" to be given to the sudo program (running lsof as oracle) or the lsof program (asking lsof, run as root, about oracle)?
 
Old 12-03-2012, 08:43 AM   #6
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Original Poster
Rep: Reputation: 24
I mean,
Quote:
sudo -u oracle lsof | wc -l
Executing the above will make the current user to switch to the oracle user & then run the lsof command.

Where as,
Quote:
sudo lsof -u oracle | wc -l
This runs the command lsof as root user to query oracle user opened files.


I'm right??

Please correct me, if 'im wrong.
 
  


Reply

Tags
lsof


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
How to have specific user-permissions for a group of files? ajaygarg Linux - Newbie 4 08-14-2012 03:01 AM
sed replacing a specific character with a specific number ieatbunnies Linux - Newbie 2 11-04-2010 11:14 AM
how to check number of opened handles ruj.sabya Linux - General 2 08-06-2007 09:37 AM
Find out the number of files currently opened closet geek Linux - Kernel 4 12-22-2006 02:45 PM
rm specific user files Longinus Linux - Newbie 1 04-27-2004 02:09 PM


All times are GMT -5. The time now is 05:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration