Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rate Thread Display Modes
Old 02-01-2007, 11:44 PM   #1
chateau_x
Prospect
 
Join Date: Apr 2005
Posts: 16
searching system as root

I have an OS X box that has a few accounts on it, how would I search all accounts for a file?

Would I need to be root? How would I do this?

Would I have to search from / after I am root?

Thanks in advance.
chateau_x is offline   Reply With Quote
Old 02-02-2007, 01:54 AM   #2
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
You don't need to be root; you can use the "sudo" command to run "find" once with privileges to search other people's folders. It is far more secure to use sudo rather than becoming root.

Code:
sudo find /Users -name "insert_filename_here"
When prompted, enter your adminstrator password. On a default Mac OS X install, you must be an admin user to use sudo.
__________________
COMPUTER TYPE
SOME SPECIFICATIONS I COPIED FROM THE BOX
STUFF I INSTALLED ALL BY MYSELF
"WITTY QUOTE"
Mikey-San is offline   Reply With Quote
Old 02-02-2007, 09:06 AM   #3
ThreeDee
Hall of Famer
 
Join Date: Aug 2005
Location: USA
Posts: 3,418
Maybe he wants to use Spotlight?
__________________
15" MacBook Pro (Mid 2010), 2.4 GHz Core i5, 10.6.5, 4GB RAM
PowerMac G4 "Quicksilver", 733 MHz, 10.4.11, 1.5GB RAM

iPod Touch 5G, 32GB, iOS 6.1.3
ThreeDee is offline   Reply With Quote
Old 02-02-2007, 10:20 AM   #4
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
Well, since he didn't say that, there's nothing wrong with what I posted.

What's your point?
__________________
COMPUTER TYPE
SOME SPECIFICATIONS I COPIED FROM THE BOX
STUFF I INSTALLED ALL BY MYSELF
"WITTY QUOTE"
Mikey-San is offline   Reply With Quote
Old 02-02-2007, 10:23 AM   #5
Squirtypoo
Triple-A Player
 
Join Date: Jan 2007
Posts: 72
Run the following command as root:
/usr/libexec/locate.updatedb

It takes a while so be patient. When it finishes any user can search the whole filesystem instantly using the locate command, eg.
locate filename
Squirtypoo is offline   Reply With Quote
Old 02-02-2007, 11:51 AM   #6
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
Quote:
Originally Posted by Squirtypoo
Run the following command as root:
/usr/libexec/locate.updatedb

It takes a while so be patient. When it finishes any user can search the whole filesystem instantly using the locate command, eg.
locate filename

I strongly recommend against this.

Exposing the entire file system to all users, without authorization, is probably not a good idea. Use find with sudo or Spotlight from the command-line with sudo.
__________________
COMPUTER TYPE
SOME SPECIFICATIONS I COPIED FROM THE BOX
STUFF I INSTALLED ALL BY MYSELF
"WITTY QUOTE"

Last edited by Mikey-San; 02-02-2007 at 12:03 PM.
Mikey-San is offline   Reply With Quote
Old 02-03-2007, 12:22 PM   #7
chateau_x
Prospect
 
Join Date: Apr 2005
Posts: 16
thanks guys, sudo worked perfectly.

Locate is not an option as I don't want to expose the entire harddrive ...

If I was logged in as root (how do i do that exactly?) could I then run SPOTLIGHT and see the entire machine across profiles?
chateau_x is offline   Reply With Quote
Old 02-03-2007, 02:59 PM   #8
trevor
Moderator
 
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,854
Quote:
If I was logged in as root (how do i do that exactly?)

Apple disables the root user as a separate login by default. This adds a layer of security that you should be hesitant to disable.

However, if you want to temporarily enable the root login, it can be done in NetInfo Manager. I would highly recommend that after you test it, you then disable the root user (also in NetInfo Manager) again.

NetInfo Manager > Security > Enable/Disable Root User

Trevor
trevor is offline   Reply With Quote
Old 02-03-2007, 06:22 PM   #9
chateau_x
Prospect
 
Join Date: Apr 2005
Posts: 16
Is there a way that I can say:

Jump onto my terminal, login as root there, then proceed as root in the GUI until I no longer need that priveledge, jumping back onto terminal and logging out.

Thanks again for the schoolin'.
chateau_x is offline   Reply With Quote
Old 02-03-2007, 06:59 PM   #10
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
Quote:
Originally Posted by chateau_x
Is there a way that I can say:

Jump onto my terminal, login as root there, then proceed as root in the GUI until I no longer need that priveledge, jumping back onto terminal and logging out.

Thanks again for the schoolin'.

This is a bad idea.

What do you need to accomplish that you need to be logged in as root in the GUI? (This is a rhetorical question. Just use sudo.)
__________________
COMPUTER TYPE
SOME SPECIFICATIONS I COPIED FROM THE BOX
STUFF I INSTALLED ALL BY MYSELF
"WITTY QUOTE"
Mikey-San is offline   Reply With Quote
Old 02-05-2007, 10:07 AM   #11
Squirtypoo
Triple-A Player
 
Join Date: Jan 2007
Posts: 72
Quote:
Originally Posted by Mikey-San
I strongly recommend against this.

Exposing the entire file system to all users, without authorization, is probably not a good idea. Use find with sudo or Spotlight from the command-line with sudo.

How can you say that locate is insecure (in huge red letters no less!) and recommend Spotlight in the same post? The locate db contains filenames, the spotlight db contains, well, everything and has several know security issues to boot. If I had some super-secret hidden folders, or if I didn't want users on my system to be able to find the location my .htaccess files I would just lock down the locate database with a chmod 600 and the locate command with a 500.

If you know of any credible security threats from using locate please post them as I update my database nightly.
Squirtypoo is offline   Reply With Quote
Old 02-05-2007, 11:19 AM   #12
Daniel_C
Triple-A Player
 
Join Date: Oct 2006
Location: New Orleans
Posts: 186
You can use an application such as Pseudo to run things as root. If you need to run finder as root open /System/Library/CoreServices/Finder.app with Pseudo.

http://personalpages.tds.net/~brian_hill/pseudo.html
__________________
Home: Dual 2GHz G5 Tower/ 2 Gigs RAM / GeForce 6800 GT DDL
Work: MacBook 2GHz Core Duo / 2 Gigs RAM
Daniel_C is offline   Reply With Quote
Old 02-05-2007, 10:06 PM   #13
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
Quote:
Originally Posted by Squirtypoo
How can you say that locate is insecure (in huge red letters no less!) and recommend Spotlight in the same post? The locate db contains filenames, the spotlight db contains, well, everything and has several know security issues to boot. If I had some super-secret hidden folders, or if I didn't want users on my system to be able to find the location my .htaccess files I would just lock down the locate database with a chmod 600 and the locate command with a 500.

If you know of any credible security threats from using locate please post them as I update my database nightly.

I did not say locate was insecure; I said locate with sudo was insecure. When you run the locate database update as root, all users will have access to the updated locate database entries for all users, without authentication, from that point on. (At least, this has been the case in the past.)

If you use sudo with find or mdfind, it's one-shot. No one gets permanent, password-free access to find and mdfind results across user domains.
__________________
COMPUTER TYPE
SOME SPECIFICATIONS I COPIED FROM THE BOX
STUFF I INSTALLED ALL BY MYSELF
"WITTY QUOTE"

Last edited by Mikey-San; 02-05-2007 at 11:21 PM.
Mikey-San is offline   Reply With Quote
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 On
HTML code is Off

Forum Jump



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


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.