Skip to content

macOS

macOS command-line tips: software updates, NTFS mounts, torrents, yt-dlp, checksums, PDF merging and faster animations.

7 min readUpdated

A collection of macOS tips that are still useful on current releases: installing updates from the Terminal, built-in and Homebrew command-line tools for audio, video, torrents and PDFs, and settings that make the interface feel faster.

The note was started in 2018 (macOS 10.13 High Sierra). Commands that only work on certain macOS versions are marked as such.

Install updates from the Terminal

softwareupdate installs system updates and downloads full macOS installers without opening System Settings.

Terminal window
# Install all available updates
softwareupdate -i -a
# Install one update, by the label shown in `softwareupdate -l`
softwareupdate -i NAME

To download a complete installer, for example to upgrade several machines or to build a USB installer, list the available versions and fetch one. --list-full-installers needs macOS 11 Big Sur or later; --fetch-full-installer needs macOS 10.15 Catalina or later.

Terminal window
# List the full installers Apple offers for this Mac
softwareupdate --list-full-installers
# Download a specific version into /Applications
softwareupdate --fetch-full-installer --full-installer-version 14.7

The installer is saved as /Applications/Install macOS <Name>.app, named after the release rather than the version number (14.7 is macOS Sonoma). Run it from the Terminal with startosinstall:

Terminal window
sudo "/Applications/Install macOS Sonoma.app/Contents/Resources/startosinstall"

Fix wrong bookmarks in Preview

If Preview bookmarks or jumps to the wrong page in a PDF, it is using the logical page numbers stored in the document. Open Preview’s settings (Preferences before macOS 13 Ventura, Settings from Ventura on), go to PDF and clear Viewing documents: Use logical page numbers.

Tested on macOS 10.13; the option may have moved in later versions.

Play audio with afplay

afplay is a built-in command-line audio player. Its syntax is afplay [option...] audio_file.

Play a file in a loop until you press Ctrl+C:

Terminal window
while :; do afplay "file.mp3"; done

Play every MP3 file in the current directory and its subdirectories, one after another:

Terminal window
find . -name '*.mp3' -exec afplay '{}' \;

Convert WAV to MP3 with ffmpeg

Install ffmpeg with brew install ffmpeg, then convert a file with the LAME encoder:

Terminal window
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3

-qscale:a 2 selects variable bitrate quality 2 on LAME’s 0 to 9 scale, where lower is better; 2 gives roughly 190 kbit/s.

Download torrents with transmission-cli

The Transmission client can run as a background daemon that you control with transmission-remote. This is useful for downloading torrent files and magnet links from the command line or over SSH.

Install Transmission and watch with Homebrew:

Terminal window
brew install transmission-cli watch

Start the daemon:

Terminal window
transmission-daemon

Add a magnet link. Always quote magnet links: they contain &, which the shell would otherwise treat as “run in the background”.

Terminal window
transmission-remote -a "magnet:?xt=urn:btih:<hash>&dn=<name>"

Watch the progress. watch refreshes every 2 seconds by default; use -n to change the interval.

Terminal window
watch "transmission-remote -l"

Stop the daemon when you are done:

Terminal window
transmission-remote --exit

Put one magnet: link per line in a file named magnet.links and add them all with this loop:

Terminal window
file="magnet.links"
while IFS= read -r line
do
transmission-remote -n 'transmission:transmission' -a "$line"
done < "$file"

-n user:password authenticates against the daemon’s RPC interface. Leave it out if RPC authentication is not enabled in the daemon’s settings.

Common transmission-remote options

Download into a specific directory with -w:

Terminal window
transmission-remote -a "magnet:?xt=urn:btih:<hash>&dn=<name>" -w ~/Downloads

Add a local .torrent file, or one from a URL:

Terminal window
transmission-remote -a file.torrent -w ~/Downloads
transmission-remote -a https://example.com/file.torrent -w ~/Downloads

Require encrypted peer connections with -er (-ep prefers encryption, -et tolerates unencrypted peers):

Terminal window
transmission-remote -a https://example.com/file.torrent -w ~/Downloads -er

Remove torrents by ID (shown in transmission-remote -l). -r removes the torrent but keeps the downloaded data; -rad deletes the data too.

Terminal window
# Remove torrent 3
transmission-remote -t 3 -r
# Remove torrents 3 and 4
transmission-remote -t 3,4 -r
# Remove all torrents
transmission-remote -t all -r

Note: In transmission-remote, -b means --debug, not “blocklist”. To use a peer blocklist, set blocklist-enabled and blocklist-url in the daemon’s settings.json, then load the list with transmission-remote --blocklist-update.

Mount NTFS drives read-write

macOS mounts NTFS drives read-only. An unsupported built-in option enables writing through /etc/fstab. Apple does not support it and it can corrupt data on the drive, so use it only on drives you can afford to lose. It was tested on macOS 10.13 and may not work on current versions.

Edit /etc/fstab (sudo vifs is the macOS tool for this; any editor run with sudo also works):

Terminal window
sudo nano /etc/fstab

Add a line for the drive, where DRIVE_NAME is the volume name. Escape spaces in the name with a backslash, for example NO\ NAME; an unescaped space splits the line into separate fields.

/etc/fstab
LABEL=DRIVE_NAME none ntfs rw,auto,nobrowse

Instead of the name, you can identify the drive by its volume UUID:

/etc/fstab
UUID=<volume-uuid> none ntfs rw

To find the UUID, open Disk Utility, select the volume and choose Info, or run diskutil info /Volumes/DRIVE_NAME and read the Volume UUID line.

Unmount and mount the drive again in Disk Utility, then check that you can write to it. With nobrowse the volume does not appear on the desktop or in the Finder sidebar; open it with open /Volumes.

Download video and audio with yt-dlp

yt-dlp downloads video and audio from YouTube and many other sites. Install it together with ffmpeg, which it uses for conversion and cutting:

Terminal window
brew install yt-dlp ffmpeg

Extract the audio track as MP3:

Terminal window
yt-dlp --extract-audio --audio-format mp3 'https://www.youtube.com/watch?v=J5oZ80Daduc'

Download as MP4, preferring the highest resolution and MP4/M4A streams, and re-encode to MP4 if needed:

Terminal window
yt-dlp -S res,ext:mp4:m4a --recode mp4 'https://www.youtube.com/watch?v=J5oZ80Daduc'

If a video needs a signed-in session (age or region restrictions), pass the cookies of a browser where you are signed in:

Terminal window
yt-dlp --cookies-from-browser safari "<url>"
yt-dlp -v -f mp4 --cookies-from-browser chrome "<url>"

Download part of a video

Extract a clip as WAV, cutting exactly at the given times:

Terminal window
yt-dlp --quiet --no-warnings --force-keyframes-at-cuts -x --audio-format wav -f bestaudio \
-o "<output_filename>" --download-sections "*<start_time>-<end_time>" "<url>"

Let ffmpeg read only part of the stream, without downloading the whole video. The times here are in seconds:

Terminal window
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 1313 -to 1330"

The ffmpeg options accept seconds or HH:MM:SS:

  • -ss: start time
  • -to: end time
  • -t: duration

The fastest way downloads only the given range, cut at the nearest keyframe:

Terminal window
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*6:02-6:22"

For exact cuts, add --force-keyframes-at-cuts (slower, because the cut points are re-encoded). inf means “to the end of the video”:

Terminal window
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*1:22:22-inf" --force-keyframes-at-cuts

Without the leading *, --download-sections takes a regular expression that matches chapter titles. This downloads the chapter titled “03. Symphony No. 6, Op. 68 (Pastoral): III. Allegro”:

Terminal window
yt-dlp 'URL' --download-sections "03.*"

Repeat the option to download several chapters, and include the chapter title in the file name:

Terminal window
yt-dlp 'URL' --download-sections "03.*" --download-sections "05.*" -o "%(title)s-%(section_title)s.%(ext)s"

Verify a SHA-256 checksum

A checksum is a fixed-length string computed from a file’s contents. If the checksum you compute matches the one published by the source, the file arrived intact and was not modified. shasum is built into macOS:

Terminal window
shasum -a 256 /path/to/file

Compare the output with the published value.

Merge PDF files with qpdf

Install qpdf with brew install qpdf. This merges whole files in order into merged.pdf:

Terminal window
qpdf --empty --pages part1.pdf part2.pdf part3.pdf -- merged.pdf

To take only some pages, put a page range after each file name:

Terminal window
qpdf --empty --pages part1.pdf 1-3 part2.pdf 1 part3.pdf -- merged.pdf

Make animations faster

These settings make macOS feel more responsive by shortening or replacing animations.

Reduce transparency and motion

In System Settings (System Preferences before macOS 13), open Accessibility and turn on:

  • Reduce transparency, under Display.
  • Reduce motion, under Display or Motion depending on the macOS version.

Reduce motion replaces the sideways sliding animation between Spaces with a quick fade. Switching Spaces by swiping and switching apps with Command+Tab both feel faster.

Speed up the Dock

This makes a hidden Dock appear faster. 0.2 is the animation time in seconds:

Terminal window
defaults write com.apple.dock autohide-time-modifier -float 0.2; killall Dock

To restore the default:

Terminal window
defaults delete com.apple.dock autohide-time-modifier; killall Dock

Speed up Launchpad

These settings apply only to macOS versions that have Launchpad (up to macOS 15 Sequoia; macOS 26 replaced it with the Apps view). Shorten the show and hide animations:

Terminal window
defaults write com.apple.dock springboard-show-duration -float 0.2; defaults write com.apple.dock springboard-hide-duration -float 0.2; killall Dock

To undo:

Terminal window
defaults delete com.apple.dock springboard-show-duration; defaults delete com.apple.dock springboard-hide-duration; killall Dock

Speed up scrolling between Launchpad pages:

Terminal window
defaults write com.apple.dock springboard-page-duration -float 0.2; killall Dock

To undo:

Terminal window
defaults delete com.apple.dock springboard-page-duration; killall Dock

References

Related notes

4 min read

Core Location in Swift

Track location in the background with Core Location, balance accuracy against battery, export GPX and fetch the points with Core Data in SwiftUI.

  • Apple & Mobile
13 min read

Swift

Swift language reference: numbers, collections, loops, functions, closures, structs and classes, protocols and optionals.

  • Apple & Mobile

Type to search the whole site.