How do I login (in the terminal) as the administrative user?

How do I login (in the terminal) as the administrative user? I am running as user and am trying to use a sudo command in the terminal. My administrative password is not accepted. Running OS 10.14.


BTW: Same question as that one from RJLJP posted on Nov 12, 2018 6∶45 PM


All answers weren't useful, unfortunately. Seems I need the root password, which I don't know.


[Re-Titled by Moderator]










iMac 27", macOS 10.14

Posted on Dec 7, 2019 12:28 PM

Reply
35 replies

Dec 7, 2019 6:22 PM in response to hexerik

Load Linux or BSD. Apple is headed away from the direction that you want here. You’re likely going to have increasing difficulties with the path you’re on with root and SIP disabled, with macOS.


Use of root is an old approach and one increasingly viewed as problematic; a lack of auditing, among other issues. Other Unix distros are headed away from allowing root logins here, too. Last I checked, Ubuntu didn’t create a root user by default.


As for your question, may I presume y’all have met the following article?

How to enable the root user on your Mac or change your root password - Apple Support


But as was mentioned in earlier replies, root is increasingly blocked:

About System Integrity Protection on your Mac - Apple Support


Dec 8, 2019 7:34 PM in response to hexerik

I have no idea what you are trying to do. The behaviour of the su and sudo commands has not changed in many years. It seems that every time someone attempts to pin you down and get you to explain exactly what you are trying to accomplish with the sudo command, you flip and start talking about the su command instead. They are different commands.


My advice to restore your system to its factory configuration still stands. I don’t know what you’ve done to it trying to get commands to work in some way that they were never designed to work. At this point, any valid command could fail because you have damaged your configuration.


This is the way things are supposed to work.

If you need to run a command as root, you run “sudo <cmd>“. If you want to just be root for a while, run a shell with sudo via “sudo bash”. If you want to change your login session to another user, then you would do “su <username>“. For example, I normally run with as a standard user. If I want to use sudo, I have to su to an admin user and then run sudo.


However, su may not work if you are trying to su into a disabled account. It depends on the system configuration. In this respect, macOS behaves identically to any previous version, or to any version of Linux, or even to Sun. If you just categorically refuse to run the correct command and want to reconfigure the system, then go for it. No one here will be able to help you.


Follow the instructions in this Apple support article to enable the root user: https://support.apple.com/HT204012

Then maybe su will work the way you want.

Dec 8, 2019 7:23 PM in response to hexerik

Sorry, no insult intended here, but when you did a fresh install did you mean a clean install where you erased the drive? Did you test it without migrating or restoring from a backup? It really sounds like your macOS installation has been corrupted in some way.


Have you tried editing the "sudoers" file from Single User mode or Recovery Mode?


Running macOS with SIP disabled is extremely dangerous in ways you may not realize. Did you hear about how a Google Chrome update broke macOS on systems with SIP disabled?

https://support.google.com/chrome/thread/15235262?hl=en

Developer's may only test their software with SIP enabled and may not realize it could have catastrophic consequences for users with SIP disabled. The same thing could happen with any software update including updates from Apple.


When I started using Linux many, many years ago (the mid to late 90's) the default was to have a separate root account, but later versions of Linux started disabling the root user and defaulted to requiring "sudo" for all root access. I was against it at first, but I soon realized "sudo" was much safer and made it easier to audit systems. Sometimes using "sudo" can make some complex commands & scripts more difficult to use or write, but there is always a way to accomplish the task using "sudo" or other methods especially on Linux without needing to enable the separate root account. When I'm a bit lazy or having problems making a command or script work with "sudo" I will use "sudo su -". I understand old habits are hard to break though and it is your system to manage like you wish (or as much as is permitted by Apple).

Dec 9, 2019 8:55 AM in response to etresoft

etresoft wrote:

I have no idea what you are trying to do. The behaviour of the su and sudo commands has not changed in many years. It seems that every time someone attempts to pin you down and get you to explain exactly what you are trying to accomplish with the sudo command, you flip and start talking about the su command instead. They are different commands.

I know. But both ask for the (root) password which I don't know. None of the passwords which are used on my system (user & administrator) are accepted.


My advice to restore your system to its factory configuration still stands. I don’t know what you’ve done to it trying to get commands to work in some way that they were never designed to work.

Weren't sudo & su never designed to work?


At this point, any valid command could fail because you have damaged your configuration.


NO - it still works fine!


This is the way things are supposed to work.
If you need to run a command as root, you run “sudo <cmd>“. If you want to just be root for a while, run a shell with sudo via “sudo bash”.

If you want to change your login session to another user, then you would do “su <username>“. For example, I normally run with as a standard user. If I want to use sudo, I have to su to an admin user and then run sudo.


Good. You probably know your root password.


However, su may not work if you are trying to su into a disabled account. It depends on the system configuration. In this respect, macOS behaves identically to any previous version, or to any version of Linux, or even to Sun. If you just categorically refuse to run the correct command ...

Which one? Can you tell me?


... want to reconfigure the system, then go for it.

I do not want to reconfigure the system - I'd just like to run su or sudo - for no particular purpose BTW, actually it isn't necessary, because I've got any access right an administrator is entitled to. Just wanted to know if anybody here has had the same experience, and how it could possibly be solved.


No one here will be able to help you.

Seems so. The only guy(s) who could help can't do this in this forum, with very good reason which I understand well.


Follow the instructions in this Apple support article to enable the root user: https://support.apple.com/HT204012
Then maybe su will work the way you want.

Thanks again. Already tried - doesn't work anymore. Seems this support article is outdated (Nov-17) and doesn't fit any more for Mojave and later versions - s. my response to MrHoffman on Dec 8, 2019 7-34 AM.


Dec 9, 2019 9:16 AM in response to hexerik

hexerik wrote:

I know. But both ask for the (root) password which I don't know. None of the passwords which are used on my system (user & administrator) are accepted.

No. They don't. But you've already been told that. The sudo command asks for the password of the current user, who must be an administrator. The su command asks for the password of the user you are assuming, which must be enabled, so it isn't going to work for root. Otherwise, anyone could just "su root" without needing a password. That wouldn't be very secure, now would it?

Weren't sudo & su never designed to work?

Weren't sudo & su never designed to work? That's a double-negative. Since they were obviously designed to work, the answer to your question would be "yes".

At this point, any valid command could fail because you have damaged your configuration.

NO - it still works fine!

Apparently not.

Good. You probably know your root password.

I don't have a root password. My root user is disabled.

However, su may not work if you are trying to su into a disabled account. It depends on the system configuration. In this respect, macOS behaves identically to any previous version, or to any version of Linux, or even to Sun. If you just categorically refuse to run the correct command ...

Which one? Can you tell me?

Which one of what? Can I tell you what? People keep telling you but you refuse to listen.

I do not want to reconfigure the system - I'd just like to run su or sudo

Then do it. There is nothing stopping you.

Just wanted to know if anybody here has had the same experience, and how it could possibly be solved.

No. Our systems work as designed and as expected. Ergo, there is nothing to be "solved".

Thanks again. Already tried - doesn't work anymore. Seems this support article is outdated (Nov-17) and doesn't fit any more for Mojave and later versions

Sure it does. I just tried it in Catalina and it works fine.


What do you have now?


1) Erase your hard drive and reinstall your operating system.

2) Restore only user accounts, no apps or other files or settings.

3) Review man pages and other documentation for sudo and su.

Dec 7, 2019 1:06 PM in response to hexerik

sudoers has restrictions such that you shouldn't even be able to read it without superuser privileges. Modifying it will outlast macOS updates and perhaps even upgrades. Be advised that modifying it from its default configuration will allow anyone to alter macOS on that Mac, for whatever purpose that may entail. I presume you know the implications of that.


Start at the beginning: are you able to even read the file?

Dec 8, 2019 11:01 AM in response to hexerik

hexerik wrote:

Oh no! This doesn't work on my system (Mojave). Why - do you think - I'm asking this question here?


Beyond a desire for enabling root and for disabling SIP, I don’t know you, nor what you know, nor what was tried or not, nor the state of the system.


TW, MrHoffman: may I know which macOS are you working on?


For this case? Both High Sierra and Mojave. Both work.


This with a simple sudo command; sudo ls was the test.


I don’t run with root enabled, nor with SIP disabled.


Catalina isn’t yet in production use around here, pending yet more work.


Have you tried this same sudo with a fresh Mojave install? Such as on a scratch external storage device? Preferably with root disabled and SIP enabled; with the install defaults. This on the possibility that there’s a corruption or a misconfiguration.


Dec 8, 2019 12:51 PM in response to hexerik

hexerik wrote:

Oh no! This doesn't work on my system (Mojave). Why - do you think - I'm asking this question here?
BTW, MrHoffman: may I know which macOS are you working on?

All versions of macOS work the same way in this respect.


What you have said doesn't make much sense. It almost sounds like the system only has a single, standard user. If that were true, then your standard user wouldn't be able to sudo. If you don't have any admin users or if you don't know their passwords, then my suggestion would be to just erase the hard drive and reinstall the operating system.


If you've turned off SIP, then you know how to use the recovery volume. You could use that to override any system settings too. In theory, you could even add a new admin user who could then perform sudo operations. Or maybe you could turn your (standard?) user into an admin. But I'm really deep into speculation at this point. But people are going to be reluctant to give you any instructions for any of that because none of this makes sense.


I suggest wiping the system and starting over. While you are waiting for the install, maybe post a question describing, at a high level, what you are ultimately trying to accomplish. We can then give you better ideas about how to do that.

Dec 7, 2019 12:47 PM in response to hexerik

hexerik wrote:

How do I login (in the terminal) as the administrative user? I am running as user and am trying to use a sudo command in the terminal. My administrative password is not accepted. Running OS 10.14.

BTW: Same question as that one from RJLJP posted on Nov 12, 2018 6∶45 PM

All answers weren't useful, unfortunately. Seems I need the root password, which I don't know.


What are you trying to accomplish?


Did you try logging into your admin account?


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I login (in the terminal) as the administrative user?

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