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

Home > Articles

This chapter is from the book

Reference 4.2 CLI Navigation

The command line is case-sensitive and requires that you use full filenames with filename extensions. For example, the CLI won’t locate the “itunes” app, but it will locate the “iTunes.app” app.

A path represents a file or folder’s location in the file system. For instance, Disk Utility’s file system path is /Applications/Utilities/Disk Utility.app. In the CLI, you use the pathname to navigate through the file system and to identify the location of items.

There are two types of file-system pathnames:

arr.jpg Absolute pathnames are full descriptions of an item location, starting from the root (or beginning) of the system (startup) volume. An absolute path begins with a forward slash (/) to indicate the beginning of the file system. An example of the absolute path to the user Joan’s Drop Box folder is /Users/joan/Public/Drop Box, which means: Start from the startup volume; go to the Users folder, then to the joan subfolder, and then to the Public subfolder; and select the item named Drop Box.

arr.jpg Relative paths are partial descriptions of an item location. They’re based on where you’re currently working in the file system. When you first open Terminal, your session starts at your home folder. The relative path from your home folder to your Drop Box is Public/Drop Box. This means: From where you are now, go into the Public subfolder, and select the item named Drop Box.

Navigate with Commands

You use three commands to navigate the file system: pwd, ls, and cd. Short for “print working directory,” pwd reports the absolute path of your current working location:

MyMac:~ joan$ pwd
/Users/joan

Short for “list,” ls lists the folder contents of your current working location. Enter a pathname following the ls command to list the contents of the specified item. The ls command has additional options for listing file and folder information that are covered throughout this lesson.

Short for “change directory,” cd is the command you use to navigate. Enter a pathname following the cd command to change your current working location to the specified folder. Entering cd without specifying a path returns you to your home folder.

Use Special Characters

You can use special characters at the prompt or in pathnames to save time and to be able to use special characters in filenames and pathnames.

Enter a space between command items to separate the items. If you don’t want the space character to separate items, use the backslash (\) before a space character.

MyMac:~ joan$ cd Public/Drop\ Box
MyMac:Drop Box joan$ pwd
/Users/joan/Public/Drop Box

Another way to enter filenames and paths with spaces is to surround filenames and paths with quotation marks:

MyMac:~ joan$ cd "Public/Drop Box"
MyMac:Drop Box joan$ pwd
/Users/joan/Public/Drop Box

You can drag and drop items from the Finder to Terminal. When you do this, Terminal enters an item’s absolute path with the appropriate backslash characters before spaces in names. Use the Tab key completion feature that’s built into the command line to automatically complete filenames and pathnames.

Other special characters include !, $, &, *, ;, |, \, parentheses, quotes, and brackets. The Finder drag-and-drop and Tab key completion parse these characters. In the CLI you can enter a backslash before any special character to treat that special character as regular text rather than as a special character.

Use double periods (..) to indicate a parent folder. For example, if you are in your home folder at /Users/username, enter cd .. to navigate to the /Users folder.

Use the tilde (~) to indicate the current user home folder in a pathname. For example, say the current user’s Drop Box is in ~/Public/. Use the tilde to specify another user’s home folder. For example, ~jill/Public specifies Jill’s Public folder.

Use Tab Key Completion

Use Tab key completion to automatically complete filenames, pathnames, and command names. Tab key completion prevents you from making typos and verifies that the item you’re entering exists.

Here’s an example of Tab key completion. Start from your home folder by entering cd, then P, and then press the Tab key. The Terminal window will flash quickly and you may hear an audible alert, letting you know there is more than one choice for items that begin with “P” in your home folder. Press the Tab key again, and the Mac will display your two choices, Pictures and Public. Now, enter u after the initial P, and then press the Tab key again, and the Mac will automatically finish Public/ for you. Finally, enter D and press the Tab key one last time, and the computer will finish the path with Public/Drop\ Box/.

When completing a folder name, Tab key completion puts a forward slash (/) at the end. It assumes that you want to continue the path. Most commands ignore the trailing slash, but a few behave differently if it’s there. You should delete the / at the end of a path.

Tab key completion reads only into folders you have permission to access. You might run into issues trying to use this feature for items that are readable only by a root user.

View Invisible Items

The CLI and the Finder hide many files and folders from view. The hidden items are often macOS support items. In the Finder, these items are set with a hidden file flag. The CLI ignores the hidden file flag and shows most hidden items. If you enter the ls command, you won’t see filenames that begin with a period. To see hidden items in long format at the command line, add the -a option to the -l option when you enter the ls command:

MyMac:~ joan$ ls -la
total 16
drwxr-xr-x+ 14 ladmin staff  448 Oct 26 01:06 .
drwxr-xr-x  5 root  admin  160 Oct 26 00:54 ..
-r--------  1 ladmin staff   7 Oct 26 00:54 .CFUserTextEncoding
drwx------  5 ladmin staff  160 Oct 26 01:06 .Trash
-rw-------  1 ladmin staff  139 Oct 26 01:06 .bash_history
drwx------  6 ladmin staff  192 Oct 26 11:29 .bash_sessions
drwx------+ 4 ladmin staff  128 Oct 26 01:06 Desktop
drwx------+ 3 ladmin staff  96 Oct 26 00:54 Documents
drwx------+ 3 ladmin staff  96 Oct 26 00:54 Downloads
drwx------@ 54 ladmin staff 1728 Oct 26 09:17 Library
drwx------+ 3 ladmin staff  96 Oct 26 00:54 Movies
drwx------+ 3 ladmin staff  96 Oct 26 00:54 Music
drwx------+ 3 ladmin staff  96 Oct 26 00:54 Pictures
drwxr-xr-x+ 4 ladmin staff  128 Oct 26 00:54 Public

Any item with a period at the beginning of its name is hidden by default in the CLI and the Finder. These items are created and used by macOS. Leave them alone.

Navigate to Other Volumes

In the CLI, the system volume is also known as the root volume, and it’s identified by a lone forward slash. Other nonroot volumes appear as part of the main file system in the Volumes folder.

Use Marks and Bookmarks

Add marks and bookmarks as you work; then use them to quickly navigate through lengthy Terminal output.

Select a line in Terminal, then choose Edit > Marks > Mark to add a mark. By default, Mark > Automatically Mark Prompt Lines is selected, so each prompt line sets a mark. Then you can choose Edit > Select Between Marks, or choose Edit > Navigate > Jump to Previous Mark, or just press Command-Up Arrow.

Choose Edit > Marks > Mark as Bookmark to add a bookmark. Then choose Edit > Bookmarks to see a list of bookmarks. Choose a bookmark to jump to that bookmark.

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