Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

From the book Exercise 29.2

Exercise 29.2
Use Single-User Mode

Prerequisite

If your computer has a Retina display, a magnifying glass may be necessary to read the text in single-user mode.

If your computer has a Retina display, a magnifying glass may be necessary to read the text in single-user mode.

When troubleshooting OS X startup issues that seem to be software-related, you might need to troubleshoot with the operating system started up in verbose or single-user mode. Verbose mode displays additional information about the startup and shutdown process, but does not change the normal operations of the computer. Single-user mode is a very primitive state of the operating system. The operating system has loaded only enough services to allow you to interact with it from the command line. It hasn’t even mounted the startup disk read/write yet. Single-user mode is a low-level maintenance mode that allows you to bring the system up, look at log files, edit or replace configuration files, and so on. In this exercise, you will start up your computer in verbose mode and then single-user mode, and then proceed to the user interface and identify various files used during startup.

If your computer has a Retina display, you may find that the text is too small to read easily in both verbose and single-user modes. In this case, using a magnifying glass is recommended.

Start up in Verbose Mode

  1. Before restarting in verbose mode, review the sequence you observed at the beginning of Exercise 29.1. In verbose mode, the basic startup sequence is the same, but what you will see on the screen is different.
  2. Restart your computer, and immediately hold down Command-V. Continue holding Command-V until you see text appear on the screen. When you reach the login window, log in as Chris Johnson.
  3. Fill in the table below with the sequence of cues you observe during a verbose startup, and contrast it with what you saw during a normal startup.
  4. Normal startup

    Verbose startup

    Startup chime


    Gray screen with Apple logo


    Gray screen with Apple logo and spinning gear


    Arrow pointer appears


    Login screen


    Desktop and Dock appear


    During the verbose segment of the startup process, you will see messages from the kernel and LaunchDaemons describing what they are doing and any problems they encounter. The messages can be somewhat cryptic if you are not familiar with the details of the kernel and LaunchDaemon’s operations. What can you discern about what is happening “behind the scenes” as your computer starts up?

  5. Shut down your computer.

As your computer shuts down, you will see that it reenters verbose mode for a few moments. This occurs after the WindowServer shuts down, but before the kernel shuts down.

Use Single-User Mode

  1. Restart your computer, and immediately hold down Command-S. Continue holding Command-S until you see text appear on the screen.
  2. Single-user mode starts off a lot like verbose mode, displaying information about the startup process. But unlike verbose mode, the startup process halts just after the system launchd starts. The graphical user interface does not start; instead, it gives you a full-screen command-line interface.

    When your computer finishes starting up into single-user mode, OS X displays instructions on how to remount the startup disk read/write and how to continue the startup process to multiuser mode, the usual run mode of OS X or any other UNIX system.

    Singleuser boot — fsck not done
    Root device is mounted read-only
    If you want to make modifications to files:
               /sbin/fsck -fy
               /sbin/mount -uw /
    If you wish to boot the system:
               exit
    :/ root#

    The last line is a prompt for you to enter a command. Note that the user name in the prompt is “root” and the prompt ends with a # instead of the more usual $. This tells you that you are logged in as the super user (root, or System Administrator). You have unrestricted access to the startup volume and the rest of the system.

  3. To force a check of the file system’s integrity, type in the command “/sbin/fsck -fy” and press Return.
  4. The computer runs a file system consistency check, correcting any errors that it finds and is able to repair. This is essentially the same as doing a Repair Disk in Disk Utility. On today’s large disks, this can take awhile, especially if there are many files and folders in the file system. This is one of the advantages of file-system journaling. Most of the time, a complete fsck does not need to occur, so startup is much faster.

    If fsck displays “The volume Macintosh HD appears to be OK”, you may proceed to the next step. If its final message is “The filesystem was modified”, it found and fixed at least one issue, and you should re-run it to make sure there are no additional issues.

  5. To remount the startup disk with write access enabled, type “/sbin/mount –uw /” and press Return.
  6. You are given a new prompt a few seconds later. This command enables you to make changes to the disk.

    This command should not generate any output if all runs correctly. If it generates an alert, double-check your typing. The most common errors with this command are to leave off the trailing “/”, or to not have spaces where they are needed.

  7. Test network connectivity from your computer to itself with the command “ping -c2 127.0.0.1”. Here, the -c2 means to try twice, and 127.0.0.1 is the address reserved for each computer to talk to itself with. The results look something like this:
  8. PING 127.0.0.1 (127.0.0.1): 56 data bytes
    ping: sendto: No route to host
    ping: sendto: No route to host
    Request timeout for icmp_seq 0
    Request timeout for icmp_seq 1
    --- 127.0.0.1 ping statistics ---
    2 packets transmitted, 0 packets received, 100.0% packet loss

    Your computer cannot even reach itself via the network because networking has not been started.

  9. Get a process listing with the command “ps -ax”.
  10. You see a much shorter list than you previously saw in Activity Monitor. At process ID 1, you see the system launchd. Process ID 2 is launchctl, which launchd uses in this case to manage the startup process. Process ID 3 is the command shell with which you are interacting. The last process is your ps command. The OS is in a very minimal state.

  11. Examine the system log file with the command “less +G /var/log/system.log”. Note that the command line is generally case sensitive, so it is important to capitalize the +G.
  12. The +G option to less tells it to start at the end of the file (that is, show the most recent log events). Usually, when you need to examine logs in single-user mode, it is because you want to find out what happened just before the system crashed, so starting at the end is more convenient than starting at the beginning. You can scan through the log by pressing “b” to move backward in the file, and pressing the Space bar to move forward.

    Unfortunately, it does not know how large the screen is, so the display can get confused as you move backward and forward. The best way to fix this is to force it to redisplay the part you are interested in by backing up past it with the “b” key, then pressing the Space bar to display forward to the part you want to read.

  13. When you are through examining the log, press “q” to exit.

Create a New Administrator Account

If you lose the password to your administrator account, you now know several ways to reset its password; but if the account becomes completely unusable, this will not allow you to regain control of the computer. In this section, you will see how to use single-user mode to create a new administrator account.

  1. Move to the /var/db folder with the command “cd /var/db”.
  2. Your prompt changes to “:db root#”, indicating that you are now in a folder named “db.” If it does not match this, the command did not work right and you must try again before proceeding. This section of the exercise involves deleting files, and since you are running as the root user, you are capable of deleting anything (or everything). It is important to be careful when you are running commands as the root user.

  3. Start typing the command “rm .AppleSe” (be sure to capitalize the “A” and “S”), but do not press Return yet.
  4. Press Tab.
  5. If you typed the command correctly, it autocompletes to “rm .AppleSetupDone ”. If pressing Tab does not make it autocomplete, you have not typed the command correctly and must correct it and try again. Note that you cannot use the mouse to select text to change, although you can use the Left and Right Arrow keys to move backward and forward on the command line.

    If you cannot get the command to autocomplete, something is still wrong and you should not proceed with the exercise. You can always press Control-C, and then use the command “exit” to exit single-user mode.

    The /var/db/.AppleSetupDone file is a placeholder file, which indicates that the Setup Assistant has run on this computer; deleting it makes the computer re-run the Setup Assistant the next time it starts up.

  6. If the command autocompleted correctly, press Return to run it.
  7. If you see a message starting with “override”, type “y” and press Return.
  8. If you see the message “rm: .AppleSetupDone: Read-only file system”, the mount command in step 3 of the previous section did not work; reenter that command, and then try again from step 2 of this section.
  9. If the rm command does not display an error, exit single-user mode with the command “exit”.
  10. The computer exits single-user mode and continues starting the operating system. With the .AppleSetupDone file gone, it runs the Setup Assistant again just as though this were a new computer.

  11. Step through the Setup Assistant screens (see Exercise 3.1 for detailed instructions). When you reach the “Create Your Computer Account” screen, enter the following information:
  12. Full Name: New Admin

    Account Name: newadmin

    If you are performing this exercise in a class, enter newadminpw in the Password and Verify fields. If you are performing this exercise on your own, you should select a more secure password for the New Admin account.

    After you finish the Setup Assistant, you are automatically logged in to the New Admin account.

  13. Open System Preferences and select the Users & Groups pane.
  14. All of your old accounts are still there; New Admin has simply been added to them.

  15. Quit System Preferences.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020