└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # macOS command-Line tools 2 | 3 | All built-in macOS command-line tools, with descriptions and usage examples. 4 | 5 | ## All commands 6 | 7 | - [`afconvert` - Audio File Convert](#afconvert---audio-file-convert) 8 | - [`afinfo` - Audio File Info](#afinfo---audio-file-info) 9 | - [`afplay` - Audio File Play](#afplay---audio-file-play) 10 | - [`airport` - Manage Apple AirPort](#airport---manage-apple-airport) 11 | - [`asr` - Apple Software Restore](#asr---apple-software-restore) 12 | - [`atsutil` - Font Registration System Utility](#atsutil---font-registration-system-utility) 13 | - [`automator` - Run an Automator Workflow](#automator---run-an-automator-workflow) 14 | - [`bless` - Set Volume Bootability and Startup Disk Options](#bless---set-volume-bootability-and-startup-disk-options) 15 | - [`caffeinate` - Prevent the System from Sleeping](#caffeinate---prevent-the-system-from-sleeping) 16 | - [`chflags` - Change a File or Folder's Flags](#chflags---change-a-file-or-folders-flags) 17 | - [`codesign` - Create and Manipulate Code Signatures](#codesign---create-and-manipulate-code-signatures) 18 | - [`createhomedir` - Create and Populate Home Directories](#createhomedir---create-and-populate-home-directories) 19 | - [`csrutil` - Configure System Integrity Protection (SIP)](#csrutil---configure-system-integrity-protection-sip) 20 | - [`cupsfilter` - Convert Files Using CUPS Filters](#cupsfilter---convert-files-using-cups-filters) 21 | - [`diskutil` - Disk Utilities](#diskutil---disk-utilities) 22 | - [`ditto` - Copy Files and Folders](#ditto---copy-files-and-folders) 23 | - [`dot_clean` - Remove Dot-Underscore Files](#dot_clean---remove-dot-underscore-files) 24 | - [`drutil` - Interact with CD/DVD Burners](#drutil---interact-with-cddvd-burners) 25 | - [`dscacheutil` - Directory Service Cache Utility](#dscacheutil---directory-service-cache-utility) 26 | - [`dscl` - Directory Service Command Line](#dscl---directory-service-command-line) 27 | - [`dseditgroup` - Edit Groups](#dseditgroup---edit-groups) 28 | - [`dsenableroot` - Enable Root Access](#dsenableroot---enable-root-access) 29 | - [`dsmemberutil` - View User and Group Rights](#dsmemberutil---view-user-and-group-rights) 30 | - [`execsnoop` - Snoop New Process Execution](#execsnoop---snoop-new-process-execution) 31 | - [`fdesetup` - FileVault Setup Utility](#fdesetup---filevault-setup-utility) 32 | - [`fs_usage` - Filesystem Activity Monitor](#fs_usage---filesystem-activity-monitor) 33 | - [`GetFileInfo` - Get HFS+ File Attributes](#getfileinfo---get-hfs-file-attributes) 34 | - [`hdiutil` - Manipulate Disk Images](#hdiutil---manipulate-disk-images) 35 | - [`installer` - Install macOS Packages](#installer---install-macos-packages) 36 | - [`iosnoop` - Monitor I/O Events](#iosnoop---monitor-io-events) 37 | - [`kextfind` - Find Kernel Extensions](#kextfind---find-kernel-extensions) 38 | - [`kextstat` - Kernel Extension Status](#kextstat---kernel-extension-status) 39 | - [`kextunload` - Unload Kernel Extensions](#kextunload---unload-kernel-extensions) 40 | - [`kickstart` - Configure Apple Remote Desktop](#kickstart---configure-apple-remote-desktop) 41 | - [`launchctl` - Manage Daemons and Agents](#launchctl---manage-daemons-and-agents) 42 | - [`lsregister` - Launch Services Database Management](#lsregister---launch-services-database-management) 43 | - [`lsbom` - List Bill of Materials](#lsbom---list-bill-of-materials) 44 | - [`mdfind` - Spotlight Search from the Command Line](#mdfind---spotlight-search-from-the-command-line) 45 | - [`mdimport` - Import Files into Spotlight Index](#mdimport---import-files-into-spotlight-index) 46 | - [`mdls` - Display Metadata Attributes](#mdls---display-metadata-attributes) 47 | - [`mdutil` - Manage Spotlight Indexing](#mdutil---manage-spotlight-indexing) 48 | - [`mkfile` - Create a File with a Specific Size](#mkfile---create-a-file-with-a-specific-size) 49 | - [`networkQuality` - Network Performance Testing](#networkquality---network-performance-testing) 50 | - [`networksetup` - Configure Network Settings](#networksetup---configure-network-settings) 51 | - [`ntfs.util` - NTFS Filesystem Utility](#ntfsutil---ntfs-filesystem-utility) 52 | - [`nvram` - Manipulate Firmware Variables](#nvram---manipulate-firmware-variables) 53 | - [`open` - Open Files and Applications](#open---open-files-and-applications) 54 | - [`opensnoop` - Monitor File Opens](#opensnoop---monitor-file-opens) 55 | - [`osacompile` - Compile AppleScript Scripts](#osacompile---compile-applescript-scripts) 56 | - [`osascript` - Execute AppleScript and Other OSA Scripts](#osascript---execute-applescript-and-other-osa-scripts) 57 | - [`pbcopy` - Copy Data to the Clipboard](#pbcopy---copy-data-to-the-clipboard) 58 | - [`pbpaste` - Paste Data from the Clipboard](#pbpaste---paste-data-from-the-clipboard) 59 | - [`pbs` - Pasteboard Server Helper Tool](#pbs---pasteboard-server-helper-tool) 60 | - [`pdisk` - Apple Partition Table Editor](#pdisk---apple-partition-table-editor) 61 | - [`pfctl` - Packet Filter Control](#pfctl---packet-filter-control) 62 | - [`pkgbuild` - Build Installer Packages](#pkgbuild---build-installer-packages) 63 | - [`pkgutil` - Package Manager Utility](#pkgutil---package-manager-utility) 64 | - [`plutil` - Property List Utility](#plutil---property-list-utility) 65 | - [`pmset` - Power Management Settings](#pmset---power-management-settings) 66 | - [`powermetrics` - Power and Performance Statistics](#powermetrics---power-and-performance-statistics) 67 | - [`profiles` - Configuration Profiles Management](#profiles---configuration-profiles-management) 68 | - [`purge` - Clear Disk Cache](#purge---clear-disk-cache) 69 | - [`qlmanage` - Quick Look Management Tool](#qlmanage---quick-look-management-tool) 70 | - [`ReportCrash` - Crash Reporting](#reportcrash---crash-reporting) 71 | - [`say` - Text-to-Speech Utility](#say---text-to-speech-utility) 72 | - [`screencapture` - Capture Screenshots](#screencapture---capture-screenshots) 73 | - [`scselect` - Switch Network Locations](#scselect---switch-network-locations) 74 | - [`scutil` - System Configuration Utility](#scutil---system-configuration-utility) 75 | - [`security` - Manage Keychains and Certificates](#security---manage-keychains-and-certificates) 76 | - [`serverinfo` - macOS Server Information](#serverinfo---macos-server-information) 77 | - [`setfile` - Set File Attributes](#setfile---set-file-attributes) 78 | - [`sharing` - Configure File Sharing](#sharing---configure-file-sharing) 79 | - [`shortcuts` - Manage macOS Shortcuts](#shortcuts---manage-macos-shortcuts) 80 | - [`shutdown` - Shutdown or Restart the System](#shutdown---shutdown-or-restart-the-system) 81 | - [`sips` - Scriptable Image Processing System](#sips---scriptable-image-processing-system) 82 | - [`softwareupdate` - Manage Software Updates](#softwareupdate---manage-software-updates) 83 | - [`spctl` - Security Policy Control](#spctl---security-policy-control) 84 | - [`sw_vers` - Show macOS Version](#sw_vers---show-macos-version) 85 | - [`system_profiler` - System Configuration Report](#system_profiler---system-configuration-report) 86 | - [`systemsetup` - Configure System Settings](#systemsetup---configure-system-settings) 87 | - [`tab2space` - Convert Tabs to Spaces](#tab2space---convert-tabs-to-spaces) 88 | - [`taskpolicy` - Set Process Resource Policies](#taskpolicy---set-process-resource-policies) 89 | - [`tccutil` - Privacy Database Management](#tccutil---privacy-database-management) 90 | - [`textutil` - Manipulate Text Files](#textutil---manipulate-text-files) 91 | - [`tmutil` - Time Machine Utility](#tmutil---time-machine-utility) 92 | - [`trimforce` - Enable TRIM for Third-Party SSDs](#trimforce---enable-trim-for-third-party-ssds) 93 | - [`ufs.util` - UFS Filesystem Utility](#ufsutil---ufs-filesystem-utility) 94 | - [`wait4path` - Wait for a Path to Become Available](#wait4path---wait-for-a-path-to-become-available) 95 | - [`wdutil` - Wireless Diagnostics Utility](#wdutil---wireless-diagnostics-utility) 96 | - [`xattr` - Extended Attributes Utility](#xattr---extended-attributes-utility) 97 | - [`xcode-select` - Manage Command Line Developer Tools](#xcode-select---manage-command-line-developer-tools) 98 | 99 | ## `afconvert` - Audio File Convert 100 | 101 | **What it does:** 102 | `afconvert` is a command-line utility that converts audio files from one format to another. It supports various formats like AIFF, WAV, MP3, AAC, and more. It also allows you to modify audio properties such as sample rate, bit depth, and channels. 103 | 104 | **Why use it:** 105 | If you need to batch-convert audio files, automate audio processing tasks, or prepare audio files for different devices and applications, `afconvert` provides a powerful way to script these conversions without using a GUI application. 106 | 107 | **Usage example:** 108 | 109 | ```bash 110 | # Convert an AIFF file to MP3 111 | afconvert input.aiff -o output.mp3 -f MP3 112 | ``` 113 | 114 | ## `afinfo` - Audio File Info 115 | 116 | **What it does:** 117 | `afinfo` displays detailed information about audio files, including format, duration, bit rate, sample rate, channels, and metadata. 118 | 119 | **Why use it:** 120 | When managing audio libraries or processing audio files, you might need to verify file properties quickly. `afinfo` allows you to inspect these details directly from the terminal, which is helpful for scripting and automation. 121 | 122 | **Usage example:** 123 | 124 | ```bash 125 | # Display information about an audio file 126 | afinfo song.m4a 127 | ``` 128 | 129 | ## `afplay` - Audio File Play 130 | 131 | **What it does:** 132 | `afplay` plays audio files from the command line. It supports common audio formats and allows you to control playback options like volume and playback rate. 133 | 134 | **Why use it:** 135 | If you're working in a terminal session and want to listen to audio files without opening a separate application, `afplay` lets you play sounds directly. It's also useful in scripts where you want to provide auditory feedback. 136 | 137 | **Usage example:** 138 | 139 | ```bash 140 | # Play an audio file 141 | afplay notification.wav 142 | ``` 143 | 144 | ## `airport` - Manage Apple AirPort 145 | 146 | **What it does:** 147 | `airport` is a command-line tool for managing Wi-Fi connections. It allows you to scan for wireless networks, connect to networks, display the status of the Wi-Fi interface, and adjust wireless settings. 148 | 149 | **Why use it:** 150 | For troubleshooting Wi-Fi issues, automating network connections, or collecting Wi-Fi diagnostics, `airport` offers control over wireless interfaces without needing to navigate through system preferences. 151 | 152 | **Usage example:** 153 | 154 | ```bash 155 | # Scan for available Wi-Fi networks 156 | airport -s 157 | ``` 158 | 159 | ## `asr` - Apple Software Restore 160 | 161 | **What it does:** 162 | `asr` is used to clone disks and restore disk images to volumes. It performs block-level copying, which can be faster than file-level copying, and supports features like encryption and compression. 163 | 164 | **Why use it:** 165 | When you need to deploy a standard system image across multiple Macs, backup a disk, or restore a system from a disk image, `asr` provides an efficient way to perform these tasks via scripting. 166 | 167 | **Usage example:** 168 | 169 | ```bash 170 | # Restore a disk image to a volume 171 | sudo asr restore --source image.dmg --target /Volumes/TargetDrive --erase 172 | ``` 173 | 174 | ## `atsutil` - Font Registration System Utility 175 | 176 | **What it does:** 177 | `atsutil` manages the Apple Type Services (ATS), including font caches. It can be used to reset font caches, verify font registrations, and troubleshoot font-related issues. 178 | 179 | **Why use it:** 180 | If you're experiencing problems with fonts not displaying correctly, corrupted fonts, or system slowdowns due to font issues, `atsutil` can help resolve these by clearing and rebuilding font caches. 181 | 182 | **Usage example:** 183 | 184 | ```bash 185 | # Reset font caches 186 | atsutil databases -remove 187 | ``` 188 | 189 | ## `automator` - Run an Automator Workflow 190 | 191 | **What it does:** 192 | `automator` executes Automator workflows from the command line. Automator allows users to create custom workflows to automate repetitive tasks using a visual interface. 193 | 194 | **Why use it:** 195 | Integrating `automator` into scripts enables you to automate complex tasks that involve GUI interactions, such as batch image processing or file organization, without manual intervention. 196 | 197 | **Usage example:** 198 | 199 | ```bash 200 | # Run an Automator workflow 201 | automator /path/to/workflow.workflow 202 | ``` 203 | 204 | ## `bless` - Set Volume Bootability and Startup Disk Options 205 | 206 | **What it does:** 207 | `bless` configures boot settings on macOS systems. It can set the startup disk, create bootable volumes, and modify boot configurations. 208 | 209 | **Why use it:** 210 | When setting up dual-boot systems, creating bootable external drives, or managing startup configurations remotely, `bless` provides the necessary control over boot settings. 211 | 212 | **Usage example:** 213 | 214 | ```bash 215 | # Set the startup disk to a specific volume 216 | sudo bless --mount /Volumes/BootVolume --setBoot 217 | ``` 218 | 219 | ## `caffeinate` - Prevent the System from Sleeping 220 | 221 | **What it does:** 222 | `caffeinate` prevents your Mac from going to sleep. It can inhibit sleep indefinitely or for a specified duration, and it can target specific sleep behaviors like display sleep. 223 | 224 | **Why use it:** 225 | Useful for ensuring long-running tasks, such as downloads, backups, or presentations, are not interrupted by the system entering sleep mode. 226 | 227 | **Usage example:** 228 | 229 | ```bash 230 | # Prevent sleep for 2 hours 231 | caffeinate -t 7200 232 | ``` 233 | 234 | ## `chflags` - Change a File or Folder's Flags 235 | 236 | **What it does:** 237 | `chflags` modifies special flags on files and directories, such as making them immutable (`uchg`), hidden, or append-only. 238 | 239 | **Why use it:** 240 | To protect critical files from accidental modification or deletion, or to hide files from standard directory listings without changing permissions. 241 | 242 | **Usage example:** 243 | 244 | ```bash 245 | # Make a file immutable 246 | chflags uchg important.doc 247 | 248 | # Remove the immutable flag 249 | chflags nouchg important.doc 250 | ``` 251 | 252 | ## `codesign` - Create and Manipulate Code Signatures 253 | 254 | **What it does:** 255 | `codesign` applies, verifies, and manages code signatures for applications and other code objects. Code signing is required for apps to pass macOS security checks like Gatekeeper. 256 | 257 | **Why use it:** 258 | If you're a developer distributing software on macOS, `codesign` ensures your apps are properly signed, which is essential for user trust and compliance with macOS security policies. 259 | 260 | **Usage example:** 261 | 262 | ```bash 263 | # Sign an application with a development certificate 264 | codesign -s "Developer ID Application: Your Name" /path/to/App.app 265 | ``` 266 | 267 | ## `createhomedir` - Create and Populate Home Directories 268 | 269 | **What it does:** 270 | `createhomedir` generates home directories for user accounts that lack them, especially in networked or directory service environments. 271 | 272 | **Why use it:** 273 | Administrators can automate the creation of home directories for new users, ensuring they have the necessary environment when they first log in. 274 | 275 | **Usage example:** 276 | 277 | ```bash 278 | # Create home directories for all users 279 | sudo createhomedir -c 280 | ``` 281 | 282 | ## `csrutil` - Configure System Integrity Protection (SIP) 283 | 284 | **What it does:** 285 | `csrutil` enables or disables System Integrity Protection, a security feature that restricts root-level access to critical system files. 286 | 287 | **Why use it:** 288 | Developers or advanced users may need to disable SIP temporarily to install certain system-level software or perform troubleshooting tasks that require modifying protected areas. 289 | 290 | **Usage example:** 291 | 292 | ```bash 293 | # Disable SIP (requires recovery mode) 294 | csrutil disable 295 | 296 | # Enable SIP 297 | csrutil enable 298 | ``` 299 | 300 | ## `cupsfilter` - Convert Files Using CUPS Filters 301 | 302 | **What it does:** 303 | `cupsfilter` processes files using the CUPS (Common UNIX Printing System) filters, converting them into printer-ready formats. 304 | 305 | **Why use it:** 306 | To convert documents to formats compatible with specific printers, or to process print jobs programmatically in custom printing workflows. 307 | 308 | **Usage example:** 309 | 310 | ```bash 311 | # Convert a PDF to a printer-specific format 312 | cupsfilter -m printer/foo input.pdf > output.pcl 313 | ``` 314 | 315 | ## `diskutil` - Disk Utilities 316 | 317 | **What it does:** 318 | `diskutil` manages disks and volumes on macOS. It can format, partition, verify, repair, mount, unmount, and erase disks. 319 | 320 | **Why use it:** 321 | For tasks like preparing new disks, repairing disk errors, managing disk partitions, or scripting disk operations without using Disk Utility's GUI. 322 | 323 | **Usage example:** 324 | 325 | ```bash 326 | # List all disks and partitions 327 | diskutil list 328 | 329 | # Erase a disk and format it as HFS+ 330 | diskutil eraseDisk HFS+ NewDiskName /dev/disk2 331 | ``` 332 | 333 | ## `ditto` - Copy Files and Folders 334 | 335 | **What it does:** 336 | `ditto` copies files and directories, preserving metadata, resource forks, and extended attributes. It can also create archives and perform incremental backups. 337 | 338 | **Why use it:** 339 | When `cp` isn't sufficient because it doesn't preserve all macOS-specific metadata, `ditto` ensures a faithful copy, making it ideal for backups and system migrations. 340 | 341 | **Usage example:** 342 | 343 | ```bash 344 | # Copy a folder and preserve metadata 345 | ditto /source/folder /destination/folder 346 | ``` 347 | 348 | ## `dot_clean` - Remove Dot-Underscore Files 349 | 350 | **What it does:** 351 | `dot_clean` merges or removes `.DS_Store` and `._` files, which store metadata on non-HFS+ file systems. 352 | 353 | **Why use it:** 354 | To clean up unnecessary files that can cause clutter or compatibility issues when transferring files to other operating systems or devices. 355 | 356 | **Usage example:** 357 | 358 | ```bash 359 | # Clean up a USB drive 360 | dot_clean /Volumes/USBDrive 361 | ``` 362 | 363 | ## `drutil` - Interact with CD/DVD Burners 364 | 365 | **What it does:** 366 | `drutil` controls optical disc drives, allowing you to burn discs, erase rewritable media, eject or close the tray, and get drive status. 367 | 368 | **Why use it:** 369 | For automating disc burning processes, managing discs in servers or kiosks, or controlling the drive without a GUI. 370 | 371 | **Usage example:** 372 | 373 | ```bash 374 | # Eject the disc tray 375 | drutil tray eject 376 | 377 | # Burn an ISO image to disc 378 | drutil burn image.iso 379 | ``` 380 | 381 | ## `dscacheutil` - Directory Service Cache Utility 382 | 383 | **What it does:** 384 | `dscacheutil` interacts with the directory service cache, allowing you to query, flush, and monitor the cache. 385 | 386 | **Why use it:** 387 | When experiencing issues with user authentication, DNS resolution, or directory services, flushing the cache can resolve outdated or corrupt data problems. 388 | 389 | **Usage example:** 390 | 391 | ```bash 392 | # Flush DNS cache 393 | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder 394 | ``` 395 | 396 | ## `dseditgroup` - Edit Groups 397 | 398 | **What it does:** 399 | `dseditgroup` manages user groups in the directory services, enabling you to create, delete, and modify group memberships. 400 | 401 | **Why use it:** 402 | Administrators can script group management tasks, such as adding users to groups or setting up permissions, essential for managing multi-user systems. 403 | 404 | **Usage example:** 405 | 406 | ```bash 407 | # Add a user to the admin group 408 | sudo dseditgroup -o edit -a username -t user admin 409 | ``` 410 | 411 | ## `dsenableroot` - Enable Root Access 412 | 413 | **What it does:** 414 | `dsenableroot` activates or deactivates the root user account on macOS. 415 | 416 | **Why use it:** 417 | In situations where `sudo` is insufficient, enabling the root account allows for direct root login, though it should be used cautiously due to security risks. 418 | 419 | **Usage example:** 420 | 421 | ```bash 422 | # Enable the root user 423 | sudo dsenableroot 424 | 425 | # Disable the root user 426 | sudo dsenableroot -d 427 | ``` 428 | 429 | ## `dsmemberutil` - View User and Group Rights 430 | 431 | **What it does:** 432 | `dsmemberutil` provides information about user and group memberships, UUIDs, and other directory service data. 433 | 434 | **Why use it:** 435 | To verify group memberships, troubleshoot permission issues, or script checks on user access rights. 436 | 437 | **Usage example:** 438 | 439 | ```bash 440 | # Check if a user is in a group 441 | dsmemberutil checkmembership -U username -G groupname 442 | ``` 443 | 444 | ## `dscl` - Directory Service Command Line 445 | 446 | **What it does:** 447 | `dscl` is a powerful tool for interacting with directory services. It can read and modify directory data, manage users and groups, and perform advanced queries. 448 | 449 | **Why use it:** 450 | For automating user and group management, scripting directory service interactions, and performing bulk operations in enterprise environments. 451 | 452 | **Usage example:** 453 | 454 | ```bash 455 | # List all local users 456 | dscl . list /Users 457 | 458 | # Create a new user 459 | sudo dscl . -create /Users/newuser 460 | ``` 461 | 462 | ## `execsnoop` - Snoop New Process Execution 463 | 464 | **What it does:** 465 | `execsnoop` monitors and displays new processes as they are executed on the system, using DTrace. 466 | 467 | **Why use it:** 468 | Useful for real-time monitoring of process execution, debugging, performance analysis, or security auditing to detect unexpected or malicious processes. 469 | 470 | **Usage example:** 471 | 472 | ```bash 473 | # Start monitoring process execution (requires sudo) 474 | sudo execsnoop 475 | ``` 476 | 477 | ## `fdesetup` - FileVault Setup Utility 478 | 479 | **What it does:** 480 | `fdesetup` configures FileVault 2 encryption. It can enable or disable encryption, manage recovery keys, and add or remove authorized users. 481 | 482 | **Why use it:** 483 | To automate the deployment of full-disk encryption across multiple systems, ensuring data security compliance in organizational environments. 484 | 485 | **Usage example:** 486 | 487 | ```bash 488 | # Enable FileVault 489 | sudo fdesetup enable 490 | 491 | # Add a user to FileVault 492 | sudo fdesetup add -usertoadd username 493 | ``` 494 | 495 | ## `fs_usage` - Filesystem Activity Monitor 496 | 497 | **What it does:** 498 | `fs_usage` displays file system activity in real-time, showing system calls and page faults related to file operations. 499 | 500 | **Why use it:** 501 | For diagnosing performance issues, monitoring application file usage, or identifying processes causing high disk activity. 502 | 503 | **Usage example:** 504 | 505 | ```bash 506 | # Monitor filesystem activity 507 | sudo fs_usage 508 | ``` 509 | 510 | ## `GetFileInfo` - Get HFS+ File Attributes 511 | 512 | **What it does:** 513 | `GetFileInfo` retrieves metadata and attributes of files on HFS+ file systems, such as file type, creator code, and flags. 514 | 515 | **Why use it:** 516 | To inspect file properties that are not visible through standard commands, particularly when dealing with legacy Mac files. 517 | 518 | **Usage example:** 519 | 520 | ```bash 521 | # Get information about a file 522 | GetFileInfo myfile.txt 523 | ``` 524 | 525 | ## `hdiutil` - Manipulate Disk Images 526 | 527 | **What it does:** 528 | `hdiutil` creates, mounts, unmounts, and manipulates disk images (.dmg files). It supports encryption, compression, and segmentation. 529 | 530 | **Why use it:** 531 | For creating custom disk images for software distribution, backups, encrypted volumes, or automating disk image tasks in scripts. 532 | 533 | **Usage example:** 534 | 535 | ```bash 536 | # Create a disk image from a folder 537 | hdiutil create -volname MyDisk -srcfolder /path/to/folder -ov -format UDZO mydisk.dmg 538 | ``` 539 | 540 | ## `installer` - Install macOS Packages 541 | 542 | **What it does:** 543 | `installer` installs macOS installer packages (.pkg files) from the command line. 544 | 545 | **Why use it:** 546 | To automate software installations, especially in deployment scripts or when setting up multiple systems without user interaction. 547 | 548 | **Usage example:** 549 | 550 | ```bash 551 | # Install a package 552 | sudo installer -pkg package.pkg -target / 553 | ``` 554 | 555 | ## `iosnoop` - Monitor I/O Events 556 | 557 | **What it does:** 558 | `iosnoop` tracks I/O events as they occur, showing which processes are performing read/write operations. 559 | 560 | **Why use it:** 561 | For performance tuning, identifying I/O bottlenecks, or monitoring disk activity for specific applications. 562 | 563 | **Usage example:** 564 | 565 | ```bash 566 | # Start monitoring I/O events (requires sudo) 567 | sudo iosnoop 568 | ``` 569 | 570 | ## `kextfind` - Find Kernel Extensions 571 | 572 | **What it does:** 573 | `kextfind` searches for kernel extensions (kexts) based on criteria like bundle identifiers, version numbers, or dependencies. 574 | 575 | **Why use it:** 576 | To locate specific kernel extensions when troubleshooting system issues or verifying driver installations. 577 | 578 | **Usage example:** 579 | 580 | ```bash 581 | # Find all kexts with a specific bundle identifier 582 | kextfind -b com.example.driver 583 | ``` 584 | 585 | ## `kextstat` - Kernel Extension Status 586 | 587 | **What it does:** 588 | `kextstat` lists currently loaded kernel extensions, showing their load addresses, dependencies, and identifiers. 589 | 590 | **Why use it:** 591 | For diagnosing kernel-related problems, ensuring necessary drivers are loaded, or checking for conflicting extensions. 592 | 593 | **Usage example:** 594 | 595 | ```bash 596 | # List all loaded kernel extensions 597 | kextstat 598 | ``` 599 | 600 | ## `kextunload` - Unload Kernel Extensions 601 | 602 | **What it does:** 603 | `kextunload` unloads a kernel extension from the running system. 604 | 605 | **Why use it:** 606 | To remove problematic drivers without rebooting, update extensions, or temporarily disable functionality for testing. 607 | 608 | **Usage example:** 609 | 610 | ```bash 611 | # Unload a kernel extension 612 | sudo kextunload /System/Library/Extensions/Example.kext 613 | ``` 614 | 615 | ## `kickstart` - Configure Apple Remote Desktop 616 | 617 | **What it does:** 618 | `kickstart` configures the Apple Remote Desktop (ARD) service, allowing you to enable remote management and set access permissions. 619 | 620 | **Why use it:** 621 | For setting up remote administration capabilities on multiple Macs, automating ARD configurations, or deploying settings in managed environments. 622 | 623 | **Usage example:** 624 | 625 | ```bash 626 | # Enable ARD and allow access for all users 627 | sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate 628 | ``` 629 | 630 | ## `launchctl` - Manage Daemons and Agents 631 | 632 | **What it does:** 633 | `launchctl` interacts with `launchd`, the service management framework for starting, stopping, and managing daemons and agents. 634 | 635 | **Why use it:** 636 | To control background services, schedule tasks, or manage startup items, essential for system administration and automation. 637 | 638 | **Usage example:** 639 | 640 | ```bash 641 | # Load a launch agent 642 | launchctl load ~/Library/LaunchAgents/com.example.agent.plist 643 | 644 | # List all loaded services 645 | launchctl list 646 | ``` 647 | 648 | ## `lsregister` - Launch Services Database Management 649 | 650 | **What it does:** 651 | `lsregister` rebuilds or resets the Launch Services database, which maps file types to applications. 652 | 653 | **Why use it:** 654 | When experiencing issues like incorrect file associations, applications not appearing in "Open With" menus, or other anomalies, `lsregister` can help fix them. 655 | 656 | **Usage example:** 657 | 658 | ```bash 659 | # Rebuild the Launch Services database 660 | /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user 661 | ``` 662 | 663 | ## `lsbom` - List Bill of Materials 664 | 665 | **What it does:** 666 | `lsbom` lists the contents of a Bill of Materials (BOM) file, which records files installed by a package. 667 | 668 | **Why use it:** 669 | To audit installed files, verify package installations, or understand what files are associated with a specific package. 670 | 671 | **Usage example:** 672 | 673 | ```bash 674 | # List files in a BOM file 675 | lsbom /var/db/receipts/com.example.pkg.bom 676 | ``` 677 | 678 | ## `mdfind` - Spotlight Search from the Command Line 679 | 680 | **What it does:** 681 | `mdfind` performs searches using Spotlight's index, allowing you to find files based on metadata and content. 682 | 683 | **Why use it:** 684 | To locate files quickly without scanning the entire filesystem, useful in scripts or when the GUI is unavailable. 685 | 686 | **Usage example:** 687 | 688 | ```bash 689 | # Find files with "report" in the name 690 | mdfind "kMDItemFSName == '*report*'" 691 | ``` 692 | 693 | ## `mdimport` - Import Files into Spotlight Index 694 | 695 | **What it does:** 696 | `mdimport` forces Spotlight to index specified files or directories. 697 | 698 | **Why use it:** 699 | To manually update the Spotlight index after adding or modifying files, ensuring they appear in search results promptly. 700 | 701 | **Usage example:** 702 | 703 | ```bash 704 | # Index a folder 705 | mdimport /path/to/folder 706 | ``` 707 | 708 | ## `mdls` - Display Metadata Attributes 709 | 710 | **What it does:** 711 | `mdls` lists the metadata attributes of a file as indexed by Spotlight, such as creation date, keywords, and content type. 712 | 713 | **Why use it:** 714 | To inspect file metadata for debugging, data analysis, or to use in scripts that process files based on attributes. 715 | 716 | **Usage example:** 717 | 718 | ```bash 719 | # Show metadata of a file 720 | mdls document.pdf 721 | ``` 722 | 723 | ## `mdutil` - Manage Spotlight Indexing 724 | 725 | **What it does:** 726 | `mdutil` enables or disables Spotlight indexing on volumes and manages the index store. 727 | 728 | **Why use it:** 729 | To prevent indexing on volumes where it's unnecessary (like backup drives), or to rebuild the index when it's corrupted. 730 | 731 | **Usage example:** 732 | 733 | ```bash 734 | # Disable indexing on a volume 735 | sudo mdutil -i off /Volumes/ExternalDrive 736 | 737 | # Rebuild the index 738 | sudo mdutil -E / 739 | ``` 740 | 741 | ## `mkfile` - Create a File with a Specific Size 742 | 743 | **What it does:** 744 | `mkfile` creates a file of a specified size, filled with null bytes. 745 | 746 | **Why use it:** 747 | For testing disk space usage, simulating large files, benchmarking, or creating placeholder files. 748 | 749 | **Usage example:** 750 | 751 | ```bash 752 | # Create a 100 MB file 753 | mkfile 100m largefile.dat 754 | ``` 755 | 756 | ## `networkQuality` - Network Performance Testing 757 | 758 | **What it does:** 759 | `networkQuality` measures network performance metrics like upload/download capacity and responsiveness. 760 | 761 | **Why use it:** 762 | To diagnose internet connection issues, test network speed, or monitor network quality over time. 763 | 764 | **Usage example:** 765 | 766 | ```bash 767 | # Run a network quality test 768 | networkQuality 769 | ``` 770 | 771 | ## `networksetup` - Configure Network Settings 772 | 773 | **What it does:** 774 | `networksetup` manages network configurations, including interfaces, locations, proxies, and DNS settings. 775 | 776 | **Why use it:** 777 | To automate network setup, switch configurations when moving between locations, or manage settings on headless systems. 778 | 779 | **Usage example:** 780 | 781 | ```bash 782 | # Set DNS servers for Wi-Fi 783 | networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4 784 | ``` 785 | 786 | ## `ntfs.util` - NTFS Filesystem Utility 787 | 788 | **What it does:** 789 | `ntfs.util` assists in mounting NTFS volumes and handling NTFS-specific tasks. 790 | 791 | **Why use it:** 792 | To access NTFS-formatted drives on macOS, particularly for reading data from Windows-formatted disks. 793 | 794 | **Usage example:** 795 | 796 | ```bash 797 | # Mount an NTFS volume (usually handled automatically) 798 | ntfs.util -m disk2s1 799 | ``` 800 | 801 | ## `nvram` - Manipulate Firmware Variables 802 | 803 | **What it does:** 804 | `nvram` reads and writes variables stored in non-volatile memory, such as boot arguments and system settings. 805 | 806 | **Why use it:** 807 | For configuring low-level system settings, troubleshooting boot issues, or setting hardware preferences. 808 | 809 | **Usage example:** 810 | 811 | ```bash 812 | # Reset NVRAM 813 | sudo nvram -c 814 | 815 | # Set a boot argument 816 | sudo nvram boot-args="-v" 817 | ``` 818 | 819 | ## `open` - Open Files and Applications 820 | 821 | **What it does:** 822 | `open` opens files, directories, or URLs in the default or specified application. It can also open applications directly. 823 | 824 | **Why use it:** 825 | To launch applications or files from the command line, integrate with scripts, or automate workflows that require opening GUI elements. 826 | 827 | **Usage example:** 828 | 829 | ```bash 830 | # Open a file with the default application 831 | open report.pdf 832 | 833 | # Open a URL in the default browser 834 | open https://www.example.com 835 | 836 | # Open a file with a specific application 837 | open -a TextEdit notes.txt 838 | ``` 839 | 840 | ## `opensnoop` - Monitor File Opens 841 | 842 | **What it does:** 843 | `opensnoop` tracks and displays files as they are opened by processes in real-time. 844 | 845 | **Why use it:** 846 | For security auditing, troubleshooting file access issues, or monitoring application behavior regarding file usage. 847 | 848 | **Usage example:** 849 | 850 | ```bash 851 | # Start monitoring file opens (requires sudo) 852 | sudo opensnoop 853 | ``` 854 | 855 | ## `osacompile` - Compile AppleScript Scripts 856 | 857 | **What it does:** 858 | `osacompile` compiles AppleScript files into compiled scripts or applications. 859 | 860 | **Why use it:** 861 | To automate the compilation of scripts for distribution, integrate scripting into build processes, or protect source code. 862 | 863 | **Usage example:** 864 | 865 | ```bash 866 | # Compile an AppleScript into an application 867 | osacompile -o MyApp.app myscript.scpt 868 | ``` 869 | 870 | ## `osascript` - Execute AppleScript and Other OSA Scripts 871 | 872 | **What it does:** 873 | `osascript` runs AppleScript or other Open Scripting Architecture (OSA) scripts from the command line. 874 | 875 | **Why use it:** 876 | To automate tasks that require interaction with GUI applications or system services that are scriptable via AppleScript. 877 | 878 | **Usage example:** 879 | 880 | ```bash 881 | # Run an AppleScript file 882 | osascript myscript.scpt 883 | 884 | # Execute an inline AppleScript 885 | osascript -e 'display dialog "Hello, world!"' 886 | ``` 887 | 888 | ## `pbcopy` - Copy Data to the Clipboard 889 | 890 | **What it does:** 891 | `pbcopy` takes standard input and places it into the clipboard (pasteboard). 892 | 893 | **Why use it:** 894 | To programmatically copy text or data into the clipboard from scripts or command output. 895 | 896 | **Usage example:** 897 | 898 | ```bash 899 | # Copy the contents of a file to the clipboard 900 | cat file.txt | pbcopy 901 | ``` 902 | 903 | ## `pbpaste` - Paste Data from the Clipboard 904 | 905 | **What it does:** 906 | `pbpaste` outputs the contents of the clipboard to standard output. 907 | 908 | **Why use it:** 909 | To retrieve data from the clipboard for use in scripts or to process clipboard contents via command-line tools. 910 | 911 | **Usage example:** 912 | 913 | ```bash 914 | # Save the clipboard contents to a file 915 | pbpaste > clipboard.txt 916 | ``` 917 | 918 | ## `pbs` - Pasteboard Server Helper Tool 919 | 920 | **What it does:** 921 | `pbs` is a background service that manages the clipboard (pasteboard) on macOS. 922 | 923 | **Why use it:** 924 | While not typically used directly, understanding `pbs` can help in troubleshooting clipboard issues or when needing to restart the service. 925 | 926 | **Usage example:** 927 | 928 | ```bash 929 | # Restart the pasteboard server 930 | killall pbs 931 | ``` 932 | 933 | ## `pdisk` - Apple Partition Table Editor 934 | 935 | **What it does:** 936 | `pdisk` edits partition maps on disks, particularly those using the Apple Partition Map (APM) scheme. 937 | 938 | **Why use it:** 939 | For managing partitions on legacy systems or disks that require APM, which is necessary for older Mac hardware or specific compatibility scenarios. 940 | 941 | **Usage example:** 942 | 943 | ```bash 944 | # List partitions on a disk 945 | pdisk /dev/disk0 -dump 946 | ``` 947 | 948 | ## `pfctl` - Packet Filter Control 949 | 950 | **What it does:** 951 | `pfctl` manages the PF firewall, allowing you to configure firewall rules, NAT, and traffic filtering. 952 | 953 | **Why use it:** 954 | To enhance network security by controlling inbound and outbound traffic, set up complex firewall rules, or manage network address translation. 955 | 956 | **Usage example:** 957 | 958 | ```bash 959 | # Load a PF configuration file 960 | sudo pfctl -f /etc/pf.conf 961 | 962 | # Enable the PF firewall 963 | sudo pfctl -e 964 | ``` 965 | 966 | ## `pkgbuild` - Build Installer Packages 967 | 968 | **What it does:** 969 | `pkgbuild` creates macOS installer packages from a payload and scripts, used for software distribution. 970 | 971 | **Why use it:** 972 | Developers and system administrators can package applications, scripts, or settings for deployment across multiple systems. 973 | 974 | **Usage example:** 975 | 976 | ```bash 977 | # Build a package from a component 978 | pkgbuild --root /path/to/root --identifier com.example.pkg --version 1.0 example.pkg 979 | ``` 980 | 981 | ## `pkgutil` - Package Manager Utility 982 | 983 | **What it does:** 984 | `pkgutil` examines and manipulates installed package receipts, allowing you to query, verify, and forget packages. 985 | 986 | **Why use it:** 987 | To troubleshoot installation issues, verify what files were installed by a package, or clean up package receipts. 988 | 989 | **Usage example:** 990 | 991 | ```bash 992 | # List all installed packages 993 | pkgutil --pkgs 994 | 995 | # Forget a package (remove its receipt) 996 | sudo pkgutil --forget com.example.pkg 997 | ``` 998 | 999 | ## `plutil` - Property List Utility 1000 | 1001 | **What it does:** 1002 | `plutil` checks, converts, and manipulates property list (plist) files, which are used for storing configuration data. 1003 | 1004 | **Why use it:** 1005 | To validate plist files, convert between binary and XML formats, or automate changes to configuration files. 1006 | 1007 | **Usage example:** 1008 | 1009 | ```bash 1010 | # Convert a binary plist to XML 1011 | plutil -convert xml1 settings.plist 1012 | 1013 | # Validate a plist file 1014 | plutil settings.plist 1015 | ``` 1016 | 1017 | ## `pmset` - Power Management Settings 1018 | 1019 | **What it does:** 1020 | `pmset` adjusts power management settings like sleep timers, hibernation modes, and wake-on-LAN. 1021 | 1022 | **Why use it:** 1023 | To optimize power usage, extend battery life, or configure systems for specific operational needs, such as servers or kiosks. 1024 | 1025 | **Usage example:** 1026 | 1027 | ```bash 1028 | # Set the display sleep timer to 15 minutes 1029 | sudo pmset displaysleep 15 1030 | 1031 | # Disable sleep mode 1032 | sudo pmset sleep 0 1033 | ``` 1034 | 1035 | ## `powermetrics` - Power and Performance Statistics 1036 | 1037 | **What it does:** 1038 | `powermetrics` provides detailed statistics on power usage, CPU activity, thermal conditions, and more. 1039 | 1040 | **Why use it:** 1041 | For performance analysis, diagnosing battery drain issues, or monitoring system health under different workloads. 1042 | 1043 | **Usage example:** 1044 | 1045 | ```bash 1046 | # Monitor CPU power usage 1047 | sudo powermetrics --samplers cpu_power 1048 | ``` 1049 | 1050 | ## `profiles` - Configuration Profiles Management 1051 | 1052 | **What it does:** 1053 | `profiles` manages user and device configuration profiles, which enforce settings and restrictions on macOS. 1054 | 1055 | **Why use it:** 1056 | To deploy settings across multiple machines, enforce security policies, or manage devices in an enterprise environment. 1057 | 1058 | **Usage example:** 1059 | 1060 | ```bash 1061 | # List installed profiles 1062 | profiles -P 1063 | 1064 | # Install a profile 1065 | sudo profiles -I -F /path/to/profile.mobileconfig 1066 | ``` 1067 | 1068 | ## `purge` - Clear Disk Cache 1069 | 1070 | **What it does:** 1071 | `purge` forces the system to clear disk caches, freeing up memory. 1072 | 1073 | **Why use it:** 1074 | For testing applications under low-memory conditions, clearing inactive memory, or troubleshooting memory-related performance issues. 1075 | 1076 | **Usage example:** 1077 | 1078 | ```bash 1079 | # Clear disk caches 1080 | sudo purge 1081 | ``` 1082 | 1083 | ## `qlmanage` - Quick Look Management Tool 1084 | 1085 | **What it does:** 1086 | `qlmanage` tests and manages Quick Look generators, which create file previews in Finder. 1087 | 1088 | **Why use it:** 1089 | To troubleshoot preview issues, test custom Quick Look plugins, or force the generation of new previews. 1090 | 1091 | **Usage example:** 1092 | 1093 | ```bash 1094 | # Preview a file using Quick Look 1095 | qlmanage -p document.pdf 1096 | 1097 | # Reset the Quick Look server 1098 | qlmanage -r 1099 | ``` 1100 | 1101 | ## `ReportCrash` - Crash Reporting 1102 | 1103 | **What it does:** 1104 | `ReportCrash` handles the logging and reporting of application crashes to Apple. 1105 | 1106 | **Why use it:** 1107 | Developers might disable `ReportCrash` during testing to prevent interference, or re-enable it to capture crash logs for troubleshooting. 1108 | 1109 | **Usage example:** 1110 | 1111 | ```bash 1112 | # Disable crash reporting 1113 | launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist 1114 | 1115 | # Enable crash reporting 1116 | launchctl load -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist 1117 | ``` 1118 | 1119 | ## `say` - Text-to-Speech Utility 1120 | 1121 | **What it does:** 1122 | `say` converts text to speech, outputting audio through the speakers or saving to an audio file. 1123 | 1124 | **Why use it:** 1125 | For accessibility purposes, creating spoken alerts in scripts, generating audio versions of text, or just for fun. 1126 | 1127 | **Usage example:** 1128 | 1129 | ```bash 1130 | # Speak a phrase 1131 | say "Hello, world!" 1132 | 1133 | # Save speech to an audio file 1134 | say -o greeting.aiff "Welcome to the system" 1135 | ``` 1136 | 1137 | ## `screencapture` - Capture Screenshots 1138 | 1139 | **What it does:** 1140 | `screencapture` takes screenshots of the screen, windows, or selected areas, saving them as image files. 1141 | 1142 | **Why use it:** 1143 | To automate screenshot capture in scripts, document processes, or capture images in remote sessions. 1144 | 1145 | **Usage example:** 1146 | 1147 | ```bash 1148 | # Capture the entire screen 1149 | screencapture screen.jpg 1150 | 1151 | # Capture a selected window after a delay 1152 | screencapture -w -T5 window.png 1153 | ``` 1154 | 1155 | ## `scselect` - Switch Network Locations 1156 | 1157 | **What it does:** 1158 | `scselect` changes the active network location, which is a set of network configurations. 1159 | 1160 | **Why use it:** 1161 | To quickly switch between different network setups, such as home and office networks, without manual reconfiguration. 1162 | 1163 | **Usage example:** 1164 | 1165 | ```bash 1166 | # List available network locations 1167 | scselect 1168 | 1169 | # Switch to a network location named "Office" 1170 | scselect "Office" 1171 | ``` 1172 | 1173 | ## `scutil` - System Configuration Utility 1174 | 1175 | **What it does:** 1176 | `scutil` interacts with the system configuration database, allowing you to query and change network settings. 1177 | 1178 | **Why use it:** 1179 | For advanced network configuration, scripting network setups, or troubleshooting connectivity issues. 1180 | 1181 | **Usage example:** 1182 | 1183 | ```bash 1184 | # Display the current hostname 1185 | scutil --get HostName 1186 | 1187 | # Set a new hostname 1188 | sudo scutil --set HostName newhostname 1189 | ``` 1190 | 1191 | ## `security` - Manage Keychains and Certificates 1192 | 1193 | **What it does:** 1194 | `security` handles tasks related to keychains, certificates, and secure storage, such as adding certificates or querying keychain items. 1195 | 1196 | **Why use it:** 1197 | To automate certificate deployment, manage authentication credentials, or script secure interactions in applications. 1198 | 1199 | **Usage example:** 1200 | 1201 | ```bash 1202 | # List all keychains 1203 | security list-keychains 1204 | 1205 | # Import a certificate 1206 | security import cert.pem -k ~/Library/Keychains/login.keychain-db 1207 | ``` 1208 | 1209 | ## `serverinfo` - macOS Server Information 1210 | 1211 | **What it does:** 1212 | `serverinfo` provides information about the macOS Server installation, including version and services. 1213 | 1214 | **Why use it:** 1215 | To verify server configurations, check for installed services, or script server management tasks. 1216 | 1217 | **Usage example:** 1218 | 1219 | ```bash 1220 | # Display server version 1221 | serverinfo --version 1222 | ``` 1223 | 1224 | ## `setfile` - Set File Attributes 1225 | 1226 | **What it does:** 1227 | `setfile` changes file attributes like creation date, visibility, or file type and creator codes. 1228 | 1229 | **Why use it:** 1230 | To adjust file properties not accessible through standard tools, useful in batch operations or when preparing files for specific applications. 1231 | 1232 | **Usage example:** 1233 | 1234 | ```bash 1235 | # Set the creation date of a file 1236 | SetFile -d "09/30/2023 12:00:00" document.txt 1237 | 1238 | # Make a file invisible 1239 | SetFile -a V hiddenfile.txt 1240 | ``` 1241 | 1242 | ## `sharing` - Configure File Sharing 1243 | 1244 | **What it does:** 1245 | `sharing` sets up shared folders and manages sharing services like AFP, FTP, and SMB. 1246 | 1247 | **Why use it:** 1248 | To automate the setup of shared resources, manage access permissions, or configure sharing services without using the GUI. 1249 | 1250 | **Usage example:** 1251 | 1252 | ```bash 1253 | # List all shared folders 1254 | sharing -l 1255 | 1256 | # Add a shared folder 1257 | sudo sharing -a /path/to/folder -s "SharedFolder" 1258 | ``` 1259 | 1260 | ## `shortcuts` - Manage macOS Shortcuts 1261 | 1262 | **What it does:** 1263 | `shortcuts` allows you to run, list, and manage Shortcuts workflows from the command line. 1264 | 1265 | **Why use it:** 1266 | To integrate Shortcuts into automation scripts, trigger workflows programmatically, or manage shortcuts in bulk. 1267 | 1268 | **Usage example:** 1269 | 1270 | ```bash 1271 | # List all available shortcuts 1272 | shortcuts list 1273 | 1274 | # Run a shortcut named "Resize Images" 1275 | shortcuts run "Resize Images" 1276 | ``` 1277 | 1278 | ## `shutdown` - Shutdown or Restart the System 1279 | 1280 | **What it does:** 1281 | `shutdown` powers off, restarts, or puts the system to sleep after a specified delay. 1282 | 1283 | **Why use it:** 1284 | For scheduling system maintenance, ensuring clean shutdowns in scripts, or remotely controlling system power states. 1285 | 1286 | **Usage example:** 1287 | 1288 | ```bash 1289 | # Shut down immediately 1290 | sudo shutdown -h now 1291 | 1292 | # Restart after 1 minute 1293 | sudo shutdown -r +1 1294 | ``` 1295 | 1296 | ## `sips` - Scriptable Image Processing System 1297 | 1298 | **What it does:** 1299 | `sips` performs basic image manipulations, including resizing, cropping, rotating, and format conversion. 1300 | 1301 | **Why use it:** 1302 | To batch process images, automate repetitive image editing tasks, or integrate image manipulation into larger scripts. 1303 | 1304 | **Usage example:** 1305 | 1306 | ```bash 1307 | # Resize an image to 800x600 pixels 1308 | sips -z 600 800 input.jpg --out output.jpg 1309 | 1310 | # Convert an image to PNG format 1311 | sips -s format png input.jpg --out output.png 1312 | ``` 1313 | 1314 | ## `softwareupdate` - Manage Software Updates 1315 | 1316 | **What it does:** 1317 | `softwareupdate` checks for, downloads, and installs macOS updates and upgrades. 1318 | 1319 | **Why use it:** 1320 | To automate system updates, manage updates across multiple machines, or integrate updates into maintenance scripts. 1321 | 1322 | **Usage example:** 1323 | 1324 | ```bash 1325 | # List available updates 1326 | softwareupdate -l 1327 | 1328 | # Install all recommended updates 1329 | sudo softwareupdate -i -r 1330 | ``` 1331 | 1332 | ## `spctl` - Security Policy Control 1333 | 1334 | **What it does:** 1335 | `spctl` manages Gatekeeper policies, controlling which applications are allowed to run based on their code signatures. 1336 | 1337 | **Why use it:** 1338 | To adjust security settings for app execution, whitelist specific applications, or troubleshoot Gatekeeper-related issues. 1339 | 1340 | **Usage example:** 1341 | 1342 | ```bash 1343 | # Add an application to the whitelist 1344 | spctl --add /Applications/Example.app 1345 | 1346 | # Check the status of an application 1347 | spctl --assess --verbose=4 /Applications/Example.app 1348 | ``` 1349 | 1350 | ## `sw_vers` - Show macOS Version 1351 | 1352 | **What it does:** 1353 | `sw_vers` displays the macOS version, build number, and product name. 1354 | 1355 | **Why use it:** 1356 | To check system version information in scripts, ensure compatibility, or log system details. 1357 | 1358 | **Usage example:** 1359 | 1360 | ```bash 1361 | # Display macOS version information 1362 | sw_vers 1363 | ``` 1364 | 1365 | ## `system_profiler` - System Configuration Report 1366 | 1367 | **What it does:** 1368 | `system_profiler` generates detailed reports of the system's hardware and software configuration. 1369 | 1370 | **Why use it:** 1371 | For inventory management, diagnostics, or collecting system information for support purposes. 1372 | 1373 | **Usage example:** 1374 | 1375 | ```bash 1376 | # Generate a full system report 1377 | system_profiler 1378 | 1379 | # Save the report to a file 1380 | system_profiler -detailLevel full > system_report.txt 1381 | ``` 1382 | 1383 | ## `systemsetup` - Configure System Settings 1384 | 1385 | **What it does:** 1386 | `systemsetup` changes system-level settings like time zone, wake settings, and network time servers. 1387 | 1388 | **Why use it:** 1389 | To automate configuration tasks, standardize settings across multiple machines, or adjust settings without user interaction. 1390 | 1391 | **Usage example:** 1392 | 1393 | ```bash 1394 | # Set the time zone 1395 | sudo systemsetup -settimezone "America/New_York" 1396 | 1397 | # Enable network time synchronization 1398 | sudo systemsetup -setusingnetworktime on 1399 | ``` 1400 | 1401 | ## `tab2space` - Convert Tabs to Spaces 1402 | 1403 | **What it does:** 1404 | `tab2space` replaces tabs with spaces in text files and ensures consistent line endings. 1405 | 1406 | **Why use it:** 1407 | To format code or text files according to style guidelines, or to prepare files for environments where tabs cause issues. 1408 | 1409 | **Usage example:** 1410 | 1411 | ```bash 1412 | # Convert tabs to spaces in a file 1413 | tab2space -t 4 input.txt > output.txt 1414 | ``` 1415 | 1416 | ## `taskpolicy` - Set Process Resource Policies 1417 | 1418 | **What it does:** 1419 | `taskpolicy` runs a command with modified resource policies, such as reduced CPU priority or I/O throttling. 1420 | 1421 | **Why use it:** 1422 | To limit the resource impact of a process, ensuring it doesn't interfere with other system activities. 1423 | 1424 | **Usage example:** 1425 | 1426 | ```bash 1427 | # Run a command with low CPU priority 1428 | taskpolicy -c low command 1429 | ``` 1430 | 1431 | ## `tccutil` - Privacy Database Management 1432 | 1433 | **What it does:** 1434 | `tccutil` manages the Transparency, Consent, and Control (TCC) database, which controls app access to protected resources. 1435 | 1436 | **Why use it:** 1437 | To reset permissions for apps accessing the camera, microphone, or other sensitive data, useful in troubleshooting or scripting privacy settings. 1438 | 1439 | **Usage example:** 1440 | 1441 | ```bash 1442 | # Reset all permissions for an app 1443 | tccutil reset All com.example.app 1444 | ``` 1445 | 1446 | ## `textutil` - Manipulate Text Files 1447 | 1448 | **What it does:** 1449 | `textutil` converts and manipulates text files in formats like TXT, RTF, DOC, HTML, and others. 1450 | 1451 | **Why use it:** 1452 | To batch convert documents, extract text from rich text files, or automate text processing tasks. 1453 | 1454 | **Usage example:** 1455 | 1456 | ```bash 1457 | # Convert a Word document to plain text 1458 | textutil -convert txt document.docx 1459 | 1460 | # Combine multiple text files into one RTF 1461 | textutil -cat rtf file1.txt file2.txt -output combined.rtf 1462 | ``` 1463 | 1464 | ## `tmutil` - Time Machine Utility 1465 | 1466 | **What it does:** 1467 | `tmutil` manages Time Machine backups, allowing you to start, stop, and configure backups. 1468 | 1469 | **Why use it:** 1470 | To automate backup processes, manage backup destinations, exclude items from backups, or restore data. 1471 | 1472 | **Usage example:** 1473 | 1474 | ```bash 1475 | # Start a backup manually 1476 | tmutil startbackup 1477 | 1478 | # Set a new backup destination 1479 | sudo tmutil setdestination /Volumes/BackupDrive 1480 | ``` 1481 | 1482 | ## `trimforce` - Enable TRIM for Third-Party SSDs 1483 | 1484 | **What it does:** 1485 | `trimforce` enables TRIM commands on non-Apple SSDs, which can improve performance and longevity. 1486 | 1487 | **Why use it:** 1488 | If you're using a third-party SSD, enabling TRIM helps maintain optimal performance, though it should be used with caution. 1489 | 1490 | **Usage example:** 1491 | 1492 | ```bash 1493 | # Enable TRIM support 1494 | sudo trimforce enable 1495 | ``` 1496 | 1497 | ## `ufs.util` - UFS Filesystem Utility 1498 | 1499 | **What it does:** 1500 | `ufs.util` handles mounting and unmounting of UFS file systems. 1501 | 1502 | **Why use it:** 1503 | For managing UFS volumes, though it's largely obsolete in modern macOS environments. 1504 | 1505 | **Usage example:** 1506 | 1507 | ```bash 1508 | # Mount a UFS filesystem 1509 | ufs.util -m disk2s1 1510 | ``` 1511 | 1512 | ## `wait4path` - Wait for a Path to Become Available 1513 | 1514 | **What it does:** 1515 | `wait4path` pauses execution until a specified file path appears in the filesystem. 1516 | 1517 | **Why use it:** 1518 | To ensure that a script doesn't proceed until a necessary resource is available, such as an external drive or network share. 1519 | 1520 | **Usage example:** 1521 | 1522 | ```bash 1523 | # Wait for a volume to mount 1524 | wait4path /Volumes/ExternalDrive 1525 | ``` 1526 | 1527 | ## `wdutil` - Wireless Diagnostics Utility 1528 | 1529 | **What it does:** 1530 | `wdutil` provides tools for capturing and analyzing wireless network diagnostics. 1531 | 1532 | **Why use it:** 1533 | For troubleshooting Wi-Fi connectivity issues, analyzing signal strength, or collecting data for support. 1534 | 1535 | **Usage example:** 1536 | 1537 | ```bash 1538 | # Start a Wi-Fi diagnostics capture 1539 | sudo wdutil capture 1540 | ``` 1541 | 1542 | ## `xattr` - Extended Attributes Utility 1543 | 1544 | **What it does:** 1545 | `xattr` reads and modifies extended attributes of files, which store metadata like quarantine status or custom properties. 1546 | 1547 | **Why use it:** 1548 | To remove quarantine flags from downloaded files, manage custom metadata, or fix issues caused by extended attributes. 1549 | 1550 | **Usage example:** 1551 | 1552 | ```bash 1553 | # List extended attributes of a file 1554 | xattr -l downloaded.app 1555 | 1556 | # Remove the quarantine attribute 1557 | xattr -d com.apple.quarantine downloaded.app 1558 | ``` 1559 | 1560 | ## `xcode-select` - Manage Command Line Developer Tools 1561 | 1562 | **What it does:** 1563 | `xcode-select` sets the active developer directory and installs command-line tools necessary for software development. 1564 | 1565 | **Why use it:** 1566 | To configure development environments, switch between multiple versions of Xcode, or install essential build tools. 1567 | 1568 | **Usage example:** 1569 | 1570 | ```bash 1571 | # Install command-line developer tools 1572 | xcode-select --install 1573 | 1574 | # Switch to a different Xcode version 1575 | sudo xcode-select -s /Applications/Xcode_12.app 1576 | ``` 1577 | --------------------------------------------------------------------------------