Apple Resources - Command Line Tools

How To Use The Mac Terminal: The Basics   

  The Mac terminal is the built-in shell environment on Mac
  that allows you to directly issue UNIX commands. That's the
  technical definition, anyway.

  In simpler terms, you can think of it as an app that gives
  you access to a deeper level of your Mac's operating system.
  Kind of like lifting the hood of your car and poking around
  the engine, but for your Mac's software.

  The Mac terminal is not a way to "hack" your computer, and
  it generally isn't going to break your computer. When I was
  first learning how the terminal worked, I remember worrying
  that I was going to enter the wrong command and completely
  brick my Mac.

  But Apple doesn't give you this kind of power easily. You
  can technically ruin your Mac by entering certain commands
  into the terminal (make sure you copy trusted commands from
  the internet on sites like StackExchange) but it's unlikely
  that you'll run into these commands during daily use.

  In short: The Mac terminal is an app that gives you greater
  control over your Mac, but has a learning curve and the
  occasional risk. That said, it's far from dangerous to
  experiment with.

Terminal User Guide   

Command Line Tools -- Install
  xcode-select --install

List Available Shells
  cat /etc/shells

  /bin/bash  (older Apple default)
  /bin/tcsh  (author's favorite)
  /bin/zsh   (Newer Apple default)

Set Default Shell Example
  chsh -s /bin/tcsh

Shell Scripting Primer   

Man[ual] Pages
  man -k say
  man say

Terminal > Help > Search

Change macOS user preferences via command line The System Preferences window is not the only way to adjust user settings. Macs come with a defaults command line interface that lets you read, write, and delete macOS user defaults. defaults write autohide-delay -float 0; killall Dock defaults write persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock defaults write AppleShowAllFiles -bool TRUE defaults write QLEnableTextSelection -bool TRUE defaults write -int 19 defaults write disable-shadow -bool TRUE defaults write location ~/Downloads defaults write FocusFollowsMouse -bool true defaults write ScheduleFrequency -int 1 defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool FALSE defaults -currentHost write disableHotPlug -bool true defaults write -g NSRequiresAquaSystemAppearance -bool Yes

Software Package Managers Home Brew ( -------------------------------------------------------------- Installed Homebrew 3.3.7 Dec.06, 2021 Homebrew Installation bash /bin/bash -c "$(curl -fsSL" note: need to add /opt/homebrew/bin to PATH set path = (/bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin /usr/local/lib /usr/lib /Developer/Tools /opt/X11/bin /opt/local/bin /opt/local/sbin /opt/homebrew/bin ~/bin) set path = (\ /bin \ /sbin \ /usr/bin \ /usr/sbin \ /usr/local/bin \ /usr/local/sbin \ /usr/local/lib \ /usr/lib \ /Developer/Tools \ /opt/X11/bin \ /opt/local/bin \ /opt/local/sbin \ /opt/homebrew/bin\ ~/bin) Example usage: brew search TEXT|/REGEX/ brew info [FORMULA|CASK...] brew install FORMULA|CASK... brew update brew upgrade [FORMULA|CASK...] brew uninstall FORMULA|CASK... brew list [FORMULA|CASK...] -1 Troubleshooting: brew config brew doctor brew install --verbose --debug FORMULA|CASK Contributing: brew create URL [--no-fetch] brew edit [FORMULA|CASK...] Further help: brew commands brew help [COMMAND] man brew open Some of this author's installations brew install exiftool brew install fping brew install hping brew install lynx brew install netpbm brew install speedtest-cli brew install telnet brew install timelimit brew install wget brew install wifi-password brew install youtube-dl brew install pdfgrep brew install pdftk-java brew install ffmpeg brew install WhatRoute brew install diff-pdf Some Casks from Patric Wardle's Objective-See brew install blockblock brew install kextviewr brew install knockknock brew install lulu brew install netiquette brew install oversight brew install ransomwhere brew install taskexplorer Cask for ChatGPT brew install vincelwt-chatgpt

SOME USEFUL COMMANDS man last last man set set man setenv setenv man echo man tr echo $PATH | tr ':' '\12' Astronomy Picture of the Day (APOD) open`date +%y%m%d`.html Download the METAR data from the Ames Airport man lynx man head lynx -dump '' | head -16 Network Interface man ifconfig ifconfig man grep man cut ifconfig `route get default | grep interface | cut -c14-17` Network Interface Quality man networkQuality networkQuality Who is on my Local Area Network (LAN) man arp arp -an | grep : man snmptable snmptable -v 2c -c public `netstat -rn | grep "default" | head -1 | cut -c20-33` ipNetToMedia man fping fping -aeg `ifconfig -l | xargs -n1 ipconfig getifaddr`/24 Internet Connections man lsof lsof -nPi Check my connection to Apple (to quit type q) man mtr mtr --aslookup --show-ips mtr --aslookup --show-ips mtr --aslookup --show-ips 2620:149:bb:9420::151 Example of downloading a YouTube Video/Audio youtube-dl youtube-dl\?v=VLPP3XmYxXg youtube-dl --extract-audio --audio-format mp3\?v=VLPP3XmYxXg Note: I have to insert the "back slash" in front of the "?" in the URL, so that it will not be treated as a special character. Perhaps you just want to listen first. open -a Safari\?v=VLPP3XmYxXg

BOOK RECOMMENDATION Top 5 Shell Scripting Books for Beginners in 2022 Take Control of the Mac Command Line with Terminal, Third Edition Copyright 2022, Joe Kissell. All rights reserved. ISBN for EPUB and Mobi version: 978-1-990783-03-6 “Welcome to Take Control of the Mac Command Line with Terminal, Third Edition, version 3.2, published in April 2022 by alt concepts. This book was written by Joe Kissell and edited by Geoff Duncan. This book introduces you to the macOS command line environment, teaching you how to use the Terminal utility to accomplish useful, interesting tasks that are either difficult or impossible to perform in the graphical interface. Most of the examples work with 10.6 Snow Leopard and later, although a few techniques require more recent versions of macOS.” Classic Shell Scripting 1st Edition by Arnold Robbins V (Author), Nelson H.F. Beebe V (Author) Shell scripting skills never go out of style. It's the shell that unlocks the real potential of Unix. Shell scripting is essential for Unix users and system administrators-a way to quickly harness and customize the full power of any Unix system. With shell scripts, you can combine the fundamental Unix text and file processing commands to crunch data and automate repetitive tasks. But beneath this simple promise lies a treacherous ocean of variations in Unix commands and standards. Classic Shell Scripting is written to help you reliably navigate these tricky waters. Writing shell scripts requires more than just a knowledge of the shell language, it also requires familiarity with the individual Unix programs: why each one is there, how to use them by themselves, and in combination with the other programs. The authors are intimately familiar with the tips and tricks that can be used to create excellent scripts, as well as the traps that can make your best effort a bad shell script. With Classic Shell Scripting you'll avoid hours of wasted effort. You'll learn not only write useful shell scripts, but how to do it properly and portably. The ability to program and customize the shell quickly, reliably, and portably to get the best out of any individual system is an important skill for anyone operating and maintaining Unix or Linux systems. Classic Shell Scripting gives you everything you need to master these essential skills.