Skip to main content

In troubleshooting a few script issues, I discovered that /dev/console is now showing ownership as root instead of the logged on user. Has anyone else seen this?

Which OS version? I haven't seen that, but would be very interested to know more since we have a boatload of scripts that use that to determine the logged in user.


Seems to be all 10.9.5. Inconsistent results though. My 10.9.5 Macbook is showing my ID as owner of /dev/console, but I definitely see root on a login script in the logs on other machines. I had to change the script to use $3.


Could be a timing thing. Root will own console when no-one is logged in, but switches ownership to the logged in user once login is done. If the script is firing too soon, it may still be seeing root as the owner of console.
Maybe place a small delay (1 second) to the script right up front so it waits until the user is fully logged in before it tries to figure out the console owner.


@luke.j.nelson, give this a go: https://macmule.com/2014/11/19/how-to-get-the-currently-logged-in-user-in-a-more-apple-approved-way/