I am using Mac OS X 10.6.4 and am struggling with the command:

diskutil

Whenever I type in diskutil the terminal says:

-bash: diskutil: command not found

Does anyone know what the problem might be? Can I install the diskutil script (probably by copying some *.sh to some destination and adding something to the bash.profile)?

link|improve this question
feedback

4 Answers

diskutil is a system administrator command. That's why it's not in the default search path for ordinary users.

The usual way to run it is to run sudo diskutil. The sudo command runs a command as the system administrator (root). sudo searches for the command in a different search path (it sets the PATH environment variable to a diffent value before searching for the command name), which includes /usr/sbin where system administrator commands such as diskutil reside.

If you do want to run diskutil as your ordinary user, specify the full path: /usr/sbin/diskutil.

link|improve this answer
While this is almost true, there are a few things you can do as a non-root user, list partitions, view the information on a mount point, etc. Basically the same stuff you can do inside of Disk Utility without unlocking it. Anything that actually presents a risk to data on disk will require root privs. – peelman Nov 20 '10 at 16:14
Actually, this answer is wrong on a couple of counts: first, OS X keeps sudo is in /usr/bin, not sbin; second, /sbin and /usr/sbin are in the default PATH for standard users as well as admins. – Gordon Davisson Nov 20 '10 at 17:18
feedback

Use:

/usr/sbin/diskutil

instead of just:

diskutil
link|improve this answer
feedback

Check your PATH (echo $PATH). diskutil is in /usr/sbin. Add it to your path if it isn't already there. If it is, then yes, diskutil is missing. (/usr/sbin/diskutil is an executable itself, not a shell script.)

link|improve this answer
could you tell me then line to add to the bash.profile in order to include /sbin/ ? – Maccaius Nov 20 '10 at 13:29
/usr/sbin doesn't belong in your ordinary users path, see Giles' answer. – SvenW Nov 20 '10 at 13:48
feedback

What does the following command say?

find / -name "diskutil"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.