‘sudo’ is missing on recovery terminal
Solution 1:
The modern mac os recovery environment automatically logs in as root. So the su or sudo command is not necessary since you are already using superuser privilages. Try the command ls -lah
to see your permessions of the current directory. Or ls -lah whoami
to see your user permissions.
Solution 2:
This is a very common misunderstanding and an understandably confusing situation.
- You are already root user in recovery terminal
- Recovery terminal dramatically changes mounted filesystem paths ( be sure / is what you think it is before making changes)
- Recovery terminal is a severely restricted shell, many commands are intentionally not available
When you take instructions that were written for a full shell (su
and sudo
), they will break. This is good since you have none of the protections (guardrails) of a normal shell so the system is designed to only work with fully qualified paths to precisely the limited subset of tools that are available. Brew is designed to not even use sudo except for specific limited setup and maintenance tasks so it uses the normal shell like the normal shell uses recovery shell. You are crossing two intentionally designed abstraction barriers to ask for brew
to run in recovery.
Think of recovery terminal as a spare tire. It’s designed to get you to a service station at low speed, not to continue your race or journey. If you get an error in recovery - that error lets you know you need better instructions or to be with a mechanic that can help with your repair. Being skilled about working in a restricted shell is a specialized area and most people don’t need to spend any time learning it. This same advice applies fairly evenly for cron
and other restricted tools or environments like containers.
So to answer your question, do not rebuild your entire tool chain in recovery, instead you can use these to restrict and encrypt your data so that someone with physical access can only destroy your data and not modify it.
- FileVault
- Firmware passwords
- Activation Lock
Solution 3:
The macOS recovery environment is on a separate, small partition of your startup disk, so /bin
, /usr/bin
, etc. are not the same folders as on your full installation of macOS. Many commands, including sudo
, are not present in the recovery environment* and I'm pretty sure none can be added manually either.
*As others have pointed out, you are automatically logged in as root
in the recovery environment so sudo
and su
are unnecessary.