Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

I cannot change the root password using another user whilst entering the correct root password

Joshuas-MacBook-Air:~ joshua$ su root passwd

Password:

/usr/bin/passwd: /usr/bin/passwd: cannot execute binary file

Joshuas-MacBook-Air:~ joshua$ su

Password:

sh-3.2# su root passwd

/usr/bin/passwd: /usr/bin/passwd: cannot execute binary file

sh-3.2# /usr/bin/passwd

Changing password for root.

New password:

Retype new password:


Please help me with this!

Earlier today I used plutil to convert the root.plist file to xml format so I could view the sha512 hash (I just started reading about it today) but I didn't back up the root.plist file - so then it caused this problem, even after I converted the file back to binary format, the terminal wouldn't have it, and gives this error even AFTER FORMATTING the macbook, please help me with this? I used to just be able to change the root password as a normal user giving the current root password, I can change the root password using the disk utility, but I don't want to do this, please help me correct this!




Apple support didn't do anything, I just got directed to speak to someone else in a shop.


Josh (I'm using some form of mountain lion - but will install mavericks now)

MacBook Air, OS X Mountain Lion (10.8.4)

Posted on Jun 1, 2014 2:55 PM

Reply
14 replies

Jun 1, 2014 6:26 PM in response to BobHarris

I have always been able to change the password via that command though? You see above that I have done it(!) - It just wont "execute binary file"


It won't let me start other files like that either, i.e. I just downloaded a program (albeit designed for linux) and tried to open it using terminal and that wouldn't open either, How can I get terminal to open the binary file???


Proof!:

sh-3.2# su root passwd

/usr/bin/passwd: /usr/bin/passwd: cannot execute binary file



Why not? I can run the command, but it won't let me access passwd like that - or any other binary file for that matter? (Someone said somewhere binary files are made for specific os's or something of the like - but this is one of the main mac files? Why can't I do this??)

Jun 1, 2014 8:37 PM in response to JoshuaBrazier

A) you are switching from sudo to su and they are not the same thing. su prompts of the password you of the account you are attempting to use, and sudo prompts for the password of the account you are currently logged in as and then expects that the account you are logged in as is an admin account or has rights on the /etc/sudoers file. And as NrHuffman has pointed out their command line syntax is different.


B) Mac OS X is not Linux, and you cannot download a Linux binary and expect it to run on Mac OS X. A script maybe, even then the script my want to use a command that does not exist on Mac OS X or a version of a command with options that is not on Mac OS X.

Jun 2, 2014 2:25 AM in response to BobHarris

But you're missing the point - the point is that I want to be able to use that command again, like I Already Could - because that error did Not come up before - and why can't I execute the binary passwd file? (This Obviously is native to the MacBook, so why can't I run it in another directory as another user? Provided I give the correct password of the user account I want to change? (Provided by the input on the command I gave beforehand as stated above as su <user> passwd) - it used to work, why not now?


These still haven't been answered? I am grateful for your replies so far, I'm just still looking for an answer to my question :(


Josh.

Jun 2, 2014 6:27 AM in response to JoshuaBrazier

The error message


Cannot execute binary file


is not telling you the binary file cannot be executed it is telling you that the shell at that point does not want a binary file, it is looking for a shell script file.

If you look at the man page for su you will see it takes a number of options then the username you are subbing. Anything after that is sent to the new shell.


So basically you are running (after the switch to the new user)


bash /usr/bin/passwd


which gives


bash-3.2$ bash /usr/bin/passwd

/usr/bin/passwd: /usr/bin/passwd: cannot execute binary file

bash-3.2$


notice the same error you got with su.


Now if you change /usr/bin/passwd to a file with shell commands it works. So

bash-3.2$ cat foo

echo "hello"

bash-3.2$ ls -l foo

-rwxr-xr-x 1 frank staff 13 Jun 2 09:16 foo

bash-3.2$


foo being a file of a single shell command echo "hello" and is executable. Now runt that

bash-3.2$ bash foo

hello

bash-3.2$


no error.

So again the error is misleading, it isnt't telling you it is a bad binary file it is tell ing you it does not want to execute a binary file.


Su and the shell have always behaved this way. I am not sure why your recollection of this is mistaken.



regards

Jun 2, 2014 6:49 AM in response to Frank Caggiano

Hmm, I sort of see where you are coming from, it's just it used to work, now it doesn't - I just want it to revert back to how it was - but there are new solutions on how to do this - still finding it wierd how the terminal still doesn't want to execute any binary file like that - as i say, how it used to - but thank you though - will re-read all solutions =)

Jun 2, 2014 6:58 AM in response to Frank Caggiano

Joshuas-MacBook-Air:/ joshua$ sudo passwd root

Changing password for root.

New password:

Retype new password:


okay... now I am really confused - the command works, as I believe recommended by others, but I still just don't understand why the command won't just execute the file and I have to do it this way - if this is how it is I'll get used to it, thanks though for your help also - now since originally what I was doing was trying to view the hash for the password of my username - how would I go about doing this? -


This is what I saw, so is this it?:

sh-3.2# defaults read /var/db/dslocal/nodes/Default/users/joshua.plist ShadowHashData

(

<62706c69 73743030 d101025f 10145341 4c544544 2d534841 3531322d 50424b44 4632d303 04050607 0857656e 74726f70 79547361 6c745a69 74657261 74696f6e 734f1080 b7e9fb90 1695e2d4 ff6bc5fc 55e57163 9f4f9cc6 be74649c d39bd2a7 2faca061 50ecd4ec 695ab308 b7307b41 ba290016 60863080 951d0d01 aa880ced d4954a7c 0772c890 92d8f111 974659be b6ace341 5055a848 c52e741e e1b6f45e bd14e278 9cb9e575 e0ef4ea9 0749c4d6 478f1c41 0d229ab3 86265a87 d41a960f 5ecccc47 4f1020bb a94eb5f7 32fefd76 4bd56d1a e049c68c 39eb4cf7 6b95be2b 432737b0 ec14d411 9e25080b 22293136 41c4e700 00000000 00010100 00000000 00000900 00000000 00000000 00000000 0000ea>

)


? Thanks guys.

Jun 2, 2014 7:04 AM in response to JoshuaBrazier

still finding it wierd how the terminal still doesn't want to execute any binary file like that

I guess I wasn;t as clear as I thought I was.


It isn't a bad binary file, the shell will never execute a binary file on startup, again try running


bash /usr/bin/passed


you get the same error as you got when you tried to do thos with su.


Again su and bash have alwasy been this way, your recollection is off.


regards

Jun 3, 2014 5:34 PM in response to JoshuaBrazier

Proof!:

sh-3.2# su root passwd

/usr/bin/passwd: /usr/bin/passwd: cannot execute binary file

su says that it takes the first argument as the login name, then the rest of the arguments are passwd to the shell, which would be whatever your login shell was set to. The default shell for Mac OS X is bash. "man bash" says:


Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file.


it doesn't say anything about the file being a binary program, rather it says it takes commands from that file, so it is expecting the file to be a script (or standard input), not a binary program.


it is the shell that is giving your this error message, no su, not sudo. It is possible that this worked for you in the past because the shell was different, or it was a different version of the shell, or you were on a different operating system, or a different version of the operating system.


User uploaded file


Notice this has nothing to do with su, and it is similar for all the shells I tried.


I also tried this on a Linux, Solaris SPARC, Solaris X86, and an IBM AIX system. Same results.


So it is possible, in the past, with a different version of the operating system, with a different shell or shell version, "su root passwd" did work. On Mac OS X today with the shells available, it does not.

I cannot change the root password using another user whilst entering the correct root password

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.