Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Is there a Unix command that shows who owns what?

Is there a Unix command that shows who owns what?
Thread Tools
Junior Member
Join Date: Apr 2001
Status: Offline
Reply With Quote
Mar 17, 2003, 09:37 PM
 
Hi everyone,

Is there a command in Unix that will show what user owns what files and directories on an entire system? Is there also a way to take the output of this and plug it into another command that lists them by files and by directories?

I realize that the output may be long, but I'm willing to take that risk :-)

Thanks!
     
Junior Member
Join Date: Apr 2001
Status: Offline
Reply With Quote
Mar 17, 2003, 09:38 PM
 
One other thing: How would I export the output of that series of commands into a text files? blah blah balh > ownership.txt?
     
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Mar 18, 2003, 12:03 AM
 
Every... file? Heh, that might be a bit more involved than you're willing to take this... that's... lots of files.

My genius scripting came up with this:

ls -l | awk '{print $3}' > ownership.txt


But that only gets one directory... and then you've stripped your output of the filenames, so there is pretty much no point... The text file would just have a bunch of user names in it heheheh
"In Nomine Patris, Et Fili, Et Spiritus Sancti"

     
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Mar 18, 2003, 05:59 AM
 
Originally posted by [APi]TheMan:
Every... file? Heh, that might be a bit more involved than you're willing to take this... that's... lots of files. :)

My genius scripting came up with this:

ls -l | awk '{print $3}' > ownership.txt


But that only gets one directory... and then you've stripped your output of the filenames, so there is pretty much no point... The text file would just have a bunch of user names in it :) heheheh
ls -l ./*

This will list files in current directory and in all its subdirectories.
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Mar 18, 2003, 08:19 AM
 
Try this:

Code:
cd / && sudo ls -lR > ~/AllFiles.txt
The 'R' flag makes it recursive -- and you need the sudo because some directories are not available to anyone but the root user.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Mar 18, 2003, 09:39 AM
 
Originally posted by Arkham_c:
Try this:

Code:
cd / && sudo ls -lR > ~/AllFiles.txt
The 'R' flag makes it recursive -- and you need the sudo because some directories are not available to anyone but the root user.
tree -u -g /


I don't know if it comes preinstalled on OS X, but fink has it.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Dedicated MacNNer
Join Date: Nov 2002
Location: Rouge River
Status: Offline
Reply With Quote
Mar 18, 2003, 09:48 AM
 
Originally posted by Arkham_c:
Try this:

Code:
cd / && sudo ls -lR > ~/AllFiles.txt
The 'R' flag makes it recursive -- and you need the sudo because some directories are not available to anyone but the root user.

Exactly. But you might want to add the 'a' flag to ls in order to get the 'hidden' files. So it would be:

Code:
sudo ls -laR / >~/AllFiles.txt
Alternatively, if he's interested only in a single user or a single file type, he could pipe it through 'grep' in order to narrow that list; it's going to be huge! On my system, there are 395911 files.
Swimming upstream since 1994.
     
Forum Regular
Join Date: Mar 2001
Location: Sydney, Australia
Status: Offline
Reply With Quote
Mar 18, 2003, 02:33 PM
 
Originally posted by Detrius:
tree -u -g /


I don't know if it comes preinstalled on OS X, but fink has it.
Not on mine....


I think this would work for you as instead. I can't get it quite right at the moment but maybe you can tinker with it

Code:
% sudo find -X / | xargs ls -ld | sort -k3 -k9 > filelist.txt
It will take a while and produce copious amounts of output!
iMac G4 800Mhz, 1Gb; Mac OS 10.3; Canon S200SP; Zip 250 USB; Canon MV30i; iPod 40Gb; Canon PowerShot G3; UMAX 1220U
iMac Rev A, 96Mb, MacOS 9.2.2
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2