Mac Recovery Mode is a powerful troubleshooting tool that allows us to restore, repair, and maintain a macOS system without the need for a separate installation disk. One of the most useful aspects of Recovery Mode is the Terminal, which provides advanced users the capability to execute essential commands for system repair, file recovery, and diagnostics. Below, we detail 10 critical Terminal commands that we can utilize within Recovery Mode to resolve various macOS issues.
1. Resetting the Administrator Password with resetpassword
If we’ve forgotten the admin password, the resetpassword
command offers a straightforward solution. This command launches a password reset utility within Recovery Mode, allowing us to reset the login credentials without needing the old password.
How to Use:
- Boot into Recovery Mode by holding down Command (⌘) + R during startup.
- Once in Recovery Mode, access the Terminal from the Utilities menu.
- Enter
resetpassword
and follow the on-screen prompts to reset the administrator password.
This command is invaluable when we need to regain access to our Mac after losing login credentials.
2. Repairing the Disk with diskutil
The diskutil
command is a powerful tool for managing disks and file systems. In Recovery Mode, it’s frequently used to repair disk errors that may prevent macOS from functioning properly.
How to Use:
- Open Terminal in Recovery Mode.
- Type
diskutil repairDisk /dev/diskX
, replacing diskX with the identifier of the disk you want to repair.
This command checks and repairs file system issues, ensuring that our system can boot and run without disk-related problems.
3. Reinstalling macOS with install
If macOS becomes unresponsive or corrupted, reinstalling the operating system is often the most effective fix. The install command provides a direct method to initiate the macOS reinstallation process from Recovery Mode.
How to Use:
- Access Terminal in Recovery Mode.
- Type
/Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/startosinstall
.
This command ensures that the latest compatible version of macOS is installed, allowing us to resolve software-related problems without erasing personal data.
4. Erasing the Disk with diskutil eraseDisk
Sometimes, a complete disk wipe is necessary, such as when we’re preparing the Mac for a fresh installation or selling it. The diskutil eraseDisk
command allows us to erase the entire disk quickly and securely.
How to Use:
- In Terminal, use the command
diskutil eraseDisk HFS+ MacintoshHD /dev/diskX
.
This command will erase the specified disk and format it as HFS+, the default macOS file system. Be cautious when using this command, as it permanently deletes all data on the disk.
5. Mounting an External Drive with mount
In Recovery Mode, mounting external drives is essential for file transfers and backups. The mount
command enables us to mount a drive and access its contents from Recovery Mode.
How to Use:
- Use
diskutil list
to identify the disk number of the external drive. - Type
sudo mount /dev/diskX /Volumes/ExternalDrive
, replacing diskX and ExternalDrive with the appropriate identifiers.
This command allows us to access data stored on an external drive, making it easier to recover important files.
6. Listing Connected Drives with diskutil list
Before performing disk operations, it’s crucial to know which drives are connected to the system. The diskutil list
command displays a detailed list of all connected drives, including internal and external disks.
How to Use:
- Type
diskutil list
in the Terminal.
This command will provide a comprehensive overview of all the disks, partitions, and file systems, enabling us to identify which disk needs to be repaired, erased, or mounted.
7. Enabling Internet Recovery with csrutil
If standard Recovery Mode is unavailable, Internet Recovery can be enabled using the csrutil
command. This command helps in turning off System Integrity Protection (SIP), which can block access to certain files and configurations.
How to Use:
- Boot into Recovery Mode and open Terminal.
- Type
csrutil disable
to disable SIP.
After running this command, we can perform deeper system modifications that are otherwise restricted when SIP is enabled.
8. Verifying Startup Disk Integrity with fsck
The fsck
(file system consistency check) command verifies and repairs issues with the startup disk. This command is essential for troubleshooting startup issues caused by disk corruption or file system errors.
How to Use:
- In Terminal, type
fsck -fy
.
This command will check the startup disk and attempt to fix any inconsistencies, ensuring that the system boots properly.
9. Restoring from Time Machine with tmutil
If a Time Machine backup is available, the tmutil
command allows us to restore the system to a previous state. This is especially useful when dealing with system corruption or when the macOS environment has been compromised.
How to Use:
- Type
tmutil restore /Volumes/TimeMachineBackup/
.
This command restores the macOS installation from a Time Machine backup, helping to recover lost data or return the system to a previous, functioning state.
10. Changing Boot Security Settings with spctl
The spctl
command allows us to adjust the macOS Gatekeeper settings, which determine whether unsigned apps can be installed on the system. In Recovery Mode, this command can disable Gatekeeper to permit the installation of third-party applications.
How to Use:
- In Terminal, type
spctl --master-disable
.
This command disables the Gatekeeper security system, allowing us to install unsigned apps or software that hasn’t been verified by Apple.
Conclusion
Using Terminal commands in Mac Recovery Mode provides powerful tools for system recovery, diagnostics, and file management. Whether we’re resetting a password, repairing a disk, reinstalling macOS, or restoring from a backup, these essential Terminal commands offer the functionality we need to restore our Mac to working condition. Understanding these commands equips us with the ability to solve a wide range of macOS issues efficiently and effectively.