4

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)?

3 Answers 3

5

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.

6
  • 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, 2010 at 16:14
  • 1
    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. Nov 20, 2010 at 17:18
  • OSX Mavericks, and /usr/sbin/diskutil isn't there.
    – OrangeDog
    Mar 12, 2014 at 11:02
  • @OrangeDog Oh, do you know where it is? I don't have access to any OSX machine. Is diskutil on the default path? Mar 12, 2014 at 11:55
  • @GordonDavisson This answer claims nothing about where sudo is. Evidently /usr/sbin (which is where diskutil was in OSX at the time) wasn't in Maccaius's PATH; was /usr/sbin in the default PATH in 10.6.4? Mar 12, 2014 at 11:58
3

Use:

/usr/sbin/diskutil

instead of just:

diskutil
1

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.)

2
  • could you tell me then line to add to the bash.profile in order to include /sbin/ ?
    – Maccaius
    Nov 20, 2010 at 13:29
  • /usr/sbin doesn't belong in your ordinary users path, see Giles' answer.
    – Sven
    Nov 20, 2010 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .