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


Set Default Shell
  chsh -s /bin/tcsh

Shell Scripting Primer   

Man[ual] Pages
  man -k say
  man say

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 Mac Ports ( -------------------------------------------------------------- Installed MacPorts-2.7.1-12-Monterey.pkg Dec.06, 2021 port help (man page) port installed sudo port -fp uninstall installed sudo port install contacts Dec.06, 2021 sudo port install mtr 0.94 (doesn't use sudo) Dec.06, 2021 sudo port install timeout (works at HE) Dec.06, 2021 sudo port install xv Dec.06, 2021 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) brew brew list -1 brew update brew info blah brew search blah brew install exiftool Dec.06, 2021 brew install fping Dec.06, 2021 brew install hping Dec.06, 2021 brew install lynx Dec.06, 2021 brew install netpbm Dec.06, 2021 brew install speedtest-cli Mar.15, 2022 brew install telnet Dec.06, 2021 brew install timelimit Dec.06, 2021 brew install wget Dec.06, 2021 brew install wifi-password Dec.06, 2021 brew install youtube-dl Dec.06, 2021 brew install pdfgrep Dec.14, 2021 brew install pdftk-java Dec.14, 2021 brew install ffmpeg May.02, 2022 brew install WhatRoute May.27, 2022

SOME USEFUL COMMANDS man last last man set set man setenv setenv man echo man tr echo $PATH | tr ':' '\12' 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 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.