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.
# Install all available updatessoftwareupdate -i -a
# Install one update, by the label shown in `softwareupdate -l`softwareupdate -i NAMETo 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.
# List the full installers Apple offers for this Macsoftwareupdate --list-full-installers
# Download a specific version into /Applicationssoftwareupdate --fetch-full-installer --full-installer-version 14.7The 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:
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:
while :; do afplay "file.mp3"; donePlay every MP3 file in the current directory and its subdirectories, one after another:
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:
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:
brew install transmission-cli watchStart the daemon:
transmission-daemonAdd a magnet link. Always quote magnet links: they contain &, which the shell would otherwise treat as “run in the background”.
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.
watch "transmission-remote -l"Stop the daemon when you are done:
transmission-remote --exitAdd many magnet links from a file
Put one magnet: link per line in a file named magnet.links and add them all with this loop:
file="magnet.links"while IFS= read -r linedo 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:
transmission-remote -a "magnet:?xt=urn:btih:<hash>&dn=<name>" -w ~/DownloadsAdd a local .torrent file, or one from a URL:
transmission-remote -a file.torrent -w ~/Downloadstransmission-remote -a https://example.com/file.torrent -w ~/DownloadsRequire encrypted peer connections with -er (-ep prefers encryption, -et tolerates unencrypted peers):
transmission-remote -a https://example.com/file.torrent -w ~/Downloads -erRemove torrents by ID (shown in transmission-remote -l). -r removes the torrent but keeps the downloaded data; -rad deletes the data too.
# Remove torrent 3transmission-remote -t 3 -r
# Remove torrents 3 and 4transmission-remote -t 3,4 -r
# Remove all torrentstransmission-remote -t all -rNote: 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):
sudo nano /etc/fstabAdd 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.
LABEL=DRIVE_NAME none ntfs rw,auto,nobrowseInstead of the name, you can identify the drive by its volume UUID:
UUID=<volume-uuid> none ntfs rwTo 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:
brew install yt-dlp ffmpegExtract the audio track as MP3:
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:
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:
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:
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:
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:
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”:
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*1:22:22-inf" --force-keyframes-at-cutsWithout 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”:
yt-dlp 'URL' --download-sections "03.*"Repeat the option to download several chapters, and include the chapter title in the file name:
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:
shasum -a 256 /path/to/fileCompare 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:
qpdf --empty --pages part1.pdf part2.pdf part3.pdf -- merged.pdfTo take only some pages, put a page range after each file name:
qpdf --empty --pages part1.pdf 1-3 part2.pdf 1 part3.pdf -- merged.pdfMake 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:
defaults write com.apple.dock autohide-time-modifier -float 0.2; killall DockTo restore the default:
defaults delete com.apple.dock autohide-time-modifier; killall DockSpeed 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:
defaults write com.apple.dock springboard-show-duration -float 0.2; defaults write com.apple.dock springboard-hide-duration -float 0.2; killall DockTo undo:
defaults delete com.apple.dock springboard-show-duration; defaults delete com.apple.dock springboard-hide-duration; killall DockSpeed up scrolling between Launchpad pages:
defaults write com.apple.dock springboard-page-duration -float 0.2; killall DockTo undo:
defaults delete com.apple.dock springboard-page-duration; killall Dock