diskutil command not found in OS X terminal

2

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

Maccaius

Posted 2010-11-20T13:01:25.573

Reputation: 61

Answers

3

Use:

/usr/sbin/diskutil

instead of just:

diskutil

Maccaius

Posted 2010-11-20T13:01:25.573

Reputation: 61

3

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.

Gilles 'SO- stop being evil'

Posted 2010-11-20T13:01:25.573

Reputation: 58 319

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 – 2010-11-20T16:14:29.077

1Actually, 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 – 2010-11-20T17:18:53.630

OSX Mavericks, and /usr/sbin/diskutil isn't there. – OrangeDog – 2014-03-12T11:02:33.393

@OrangeDog Oh, do you know where it is? I don't have access to any OSX machine. Is diskutil on the default path? – Gilles 'SO- stop being evil' – 2014-03-12T11:55:48.987

@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? – Gilles 'SO- stop being evil' – 2014-03-12T11:58:13.150

I don't have a 10.6.4 system handy, but under both 10.6.8 and 10.9.2, the default PATH is /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin, diskutil is in /usr/sbin, and sudo is in /usr/bin. So, both sudo and diskutil have been in the default PATH for a long time and are still there. Not sure why diskutil is missing on @OrangeDog's Mac... – Gordon Davisson – 2014-03-12T16:06:51.267

0

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

JRobert

Posted 2010-11-20T13:01:25.573

Reputation: 6 128

could you tell me then line to add to the bash.profile in order to include /sbin/ ? – Maccaius – 2010-11-20T13:29:23.977

/usr/sbin doesn't belong in your ordinary users path, see Giles' answer. – Sven – 2010-11-20T13:48:17.903