Skip to content

Guide to Command-Line Tools on macOS

Published: at 02:00 PM

Introduction

Understanding macOS terminal commands can greatly enhance your efficiency and control over your system. From managing clipboard contents and opening applications to configuring system settings and handling file attributes, these commands offer powerful solutions to everyday tasks. By incorporating these techniques into your workflow, you can streamline operations, automate processes with osascript, and fully leverage the capabilities of your macOS environment. Keep experimenting and exploring to unlock even more potential from your terminal commands.

In this article we will focus on the macOS specific command line tools, for generic unix/linux commands you can check other articles:

TL;DR

You can find a shorter cheat sheet version of this article here.

Table of contents

Open Table of contents

Basic Commands

Clipboard Management

Managing the clipboard from the terminal can be incredibly useful for quickly copying and pasting text, command outputs, or even entire files. Here are some handy clipboard commands:

Checking Application Entitlements

To check the entitlements of an application, which are permissions granted to it by macOS, use the following command:

Opening Applications and Files

The open command is a tool to open applications, files, or URLs directly from the terminal. Here are various ways to use it:

Opening Web Pages

You can also open web pages directly from the terminal:

Additional Arguments

The open command supports additional arguments to customize its behavior:

Finder

You can control Finder’s behavior using defaults commands:

Extended File Attributes

Extended attributes provide additional metadata about files. You can manage these using the xattr command:

Spotlight

Spotlight search can be leveraged from the terminal using mdfind:

Disabling/Enabling Spotlight

You can control Spotlight indexing with mdutil:

Computer Name Management

You can get and set various computer names using scutil:

Changing Computer Name

AppleScript (osascript)

Use osascript to execute AppleScript or JavaScript from the terminal:

Volume Control

Control the system volume using osascript:

Text-to-Speech with say

Convert text to speech using the say command:

Disk Management

FileVault

Manage FileVault encryption status and users:

Encrypted DMG Volumes

Building Packages with pkgbuild

Create installer packages with pkgbuild:

Options:

Universal Binary Files

Manage universal (fat) binaries with lipo:

Property List Utility (plutil)

Manage property list files with plutil:

Reading Plist Files

Common Plist Examples:

Creating Plist Files

Conclusion

Mastering these macOS terminal commands can significantly boost your productivity and streamline your workflow. Whether you’re manipulating clipboard contents, opening applications and files, managing Finder settings, or utilizing Spotlight for advanced searches, these commands offer powerful and efficient ways to interact with your system. By incorporating these techniques into your daily routine, you can enhance your ability to perform a variety of tasks more quickly and effectively. Explore these commands and discover how they can simplify your macOS experience.