 |
 |
Is there a Unix command that shows who owns what?
|
 |
|
 |
|
Junior Member
Join Date: Apr 2001
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|