A curated list of shell commands and tools specific to OS X.
Terminal: This is the actual interface to the console. The program we use to interact with the console is actually a “terminal emulator”, providing us the experience of typing into an old school terminal from the convenience of our modern graphical operating system. Home » How-To » 10 Mac OS Terminal Commands that You Should Know. 10 Mac OS Terminal Commands that You Should Know. December 19, 2017. Do you want to customize your Mac and make it fit your needs completely? Then you are welcome to read this article about the best user and interface tricks you can easily apply to your computer. Now, I'm not saying that learning Terminal commands is easy, but using them definitely is. I've compiled a list of some basic commands that will get you started on your journey to mastering Mac OS X, whether it's Mavericks, Yosemite, or even an older system like Lion. Now, I'm not saying that learning Terminal commands is easy, but using them definitely is. I've compiled a list of some basic commands that will get you started on your journey to mastering Mac OS X, whether it's Mavericks, Yosemite, or even an older system like Lion.
“You don’t have to know everything. You simply need to know where to find it when necessary.” (John Brunner) Best chess game for mac.
If you want to contribute, you are highly encouraged to do so. Please read the contribution guidelines.
For more terminal shell goodness, please also see this list's sister list Awesome Command Line Apps.
Caffeinating
When you find something helpful in here, you could buy me a coffee. I spend a lot of time and effort on curating this list. Keeping me properly caffeinated accelerates things. And it would really make my day. Kindness of strangers and all that. If you can't or won't, no hard feelings. It's available completely free for a reason. Still, it would be awesome.
Patreon: https://www.patreon.com/herrbischoff
Contents
AppearanceTransparencyTransparency in Menu and WindowsWallpaperSet WallpaperApplicationsApp StoreList All Apps Downloaded from App StoreShow Debug Menu
Works up to Yosemite.
Apple Remote DesktopKickstart Manual PagesActivate And Deactivate the ARD Agent and HelperEnable and Disable Remote Desktop SharingRemove Apple Remote Desktop SettingsContactsDebug ModeUninstall Google UpdateiTunesKeyboard Media Keys
This works up to Yosemite. System Integrity Protection was introduced in El Capitan which prevents system Launch Agents from being unloaded.
From El Capitan onwards, you can either disable SIP or resort to a kind of hack, which will make iTunes inaccessible to any user, effectively preventing it from starting itself or its helpers. Be aware that for all intents and purposes this will trash your iTunes installation and may conflict with OS updates down the road.
Show Attachments as IconsVacuum Mail Index
The AppleScript code below will quit Mail, vacuum the SQLite index, then re-open Mail. On a large email database that hasn't been optimized for a while, this can provide significant improvements in responsiveness and speed.
SafariChange Default FontsEnable Develop Menu and Web InspectorGet Current Page Data
Other options:
get source , get text .
Use Backspace/Delete to Go Back a PageSketchExport Compact SVGsSkimTurn Off Auto Reload Dialog
Removes the dialog and defaults to auto reload.
TerminalFocus Follows MouseTextEditUse Plain Text Mode as DefaultVisual Studio CodeFix VSCodeVim Key RepeatBackupTime MachineChange Backup Interval
This changes the interval to 30 minutes. The integer value is the time in seconds.
Local Backups
Whether Time Machine performs local backups while the Time Machine backup volume is not available.
Since High Sierra, you cannot disable local snapshots. Time Machine now always creates a local APFS snapshot and uses that snapshot as the data source to create a regular backup, rather than using the live disk as the source, as is the case with HFS formatted disks.
Prevent Time Machine from Prompting to Use New Hard Drives as Backup VolumeShow Time Machine Logs
This little script will output the last 12 hours of Time Machine activity followed by live activity.
Toggle Backup While on BatteryVerify Backup
Beginning in OS X 10.11, Time Machine records checksums of files copied into snapshots. Checksums are not retroactively computed for files that were copied by earlier releases of OS X.
DeveloperVimCompile Sane Vim
Compiling MacVim via Homebrew with all bells and whistles, including overriding system Vim.
Neovim
Install the modern Vim drop-in alternative via Homebrew.
XcodeInstall Command Line Tools without XcodeRemove All Unavailable SimulatorsDockAdd a Stack with Recent ApplicationsAdd a Nameless Stack Folder and Small Spacer![]() Add a SpaceAdd a Small SpaceAuto Rearrange Spaces Based on Most Recent UseAutohideIcon Bounce
Global setting whether Dock icons should bounce when the respective application demands your attention.
Lock the Dock SizeReset DockResize
Fully resize your Dock's body. To resize change the
0 value as an integer.
Scroll Gestures
Use your touchpad or mouse scroll wheel to interact with Dock items. Allows you to use an upward scrolling gesture to open stacks. Using the same gesture on applications that are running invokes Exposé/Mission Control.
Set Auto Show/Hide Delay
The float number defines the show/hide delay in ms.
Show Hidden App IconsShow Only Active ApplicationsSingle App Mode
When clicking an application icon in the Dock, the respective windows will cometo the front, but all other application windows will be hidden.
DocumentsConvert File to HTML
Supported formats are plain text, rich text (rtf) and Microsoft Word (doc/docx).
Files, Disks and VolumesCreate an Empty File
Creates an empty 10 gigabyte test file.
Disable Sudden Motion Sensor
Leaving this turned on is useless when you're using SSDs.
Eject All Mountable Volumes
The only reliable way to do this is by sending an AppleScript command to Finder.
Repair File Permissions
You don't have to use the Disk Utility GUI for this.
Beginning with OS X El Capitan, system file permissions are automatically protected. It's no longer necessary to verify or repair permissions with Disk Utility. (Source)
Set Boot VolumeShow All Attached Disks and PartitionsView File System Usage
A continuous stream of file system access info.
APFS
Available since High Sierra. There is no central utility and usage is inconsistent as most functionality is rolled into
tmutil .
Convert Volume from HFS+ to APFSCreate New APFS FilesystemCreate SnapshotDelete SnapshotList SnapshotsMount Snapshot
Snapshots are read-only.
Disk ImagesCreate Disk Image From Folder Contents
If you'd like to encrypt the disk image:
By default, you'll be prompted for a password. You can automate that by piping in a password:
Burn Disk Images to DVD
This command applies to .iso, .img and .dmg images.
Disable Disk Image VerificationMake Volume OS X BootableMount Disk ImageUnmount Disk ImageWrite Disk Image to Volume
Like the Disk Utility 'Restore' function.
FinderDesktopShow External Media
External HDs, thumb drives, etc.
Show Internal Media
Built-in HDs or SSDs.
Show Removable Media
CDs, DVDs, iPods, etc.
Show Network Volumes
AFP, SMB, NFS, WebDAV, etc.
Files and FoldersClear All ACLsHide Folder in FinderShow All File ExtensionsShow Hidden FilesRemove Protected FlagShow Full Path in Finder TitleUnhide User Library FolderIncrease Number of Recent PlacesLayoutShow 'Quit Finder' Menu Item
Makes possible to see Finder menu item 'Quit Finder' with default shortcut Cmd + Q
Smooth Scrolling
Useful if you’re on an older Mac that messes up the animation.
Rubberband ScrollingExpand Save Panel by DefaultDesktop Icon VisibilityPath BarScrollbar Visibility
Possible values:
WhenScrolling , Automatic and Always .
Status BarSave to Disk by Default
Sets default save target to be a local disk, not iCloud.
Set Current Folder as Default Search ScopeSet Default Finder Location to Home FolderSet Sidebar Icon Size
Sets size to 'medium'.
Metadata FilesDisable Creation of Metadata Files on Network Volumes
Avoids creation of
.DS_Store and AppleDouble files.
Disable Creation of Metadata Files on USB Volumes
Avoids creation of
.DS_Store and AppleDouble files.
Opening ThingsChange Working Directory to Finder Path
If multiple windows are open, it chooses the top-most one.
Open URLOpen FileOpen Applications
You can open applications using
-a . https://treetribal320.weebly.com/blog/best-email-program-for-mac-sierra.
Open FolderOpen Current FolderFontsClear Font Cache for Current User
To clear font caches for all users, put
sudo in front of this command.
Get SF Mono Fonts
You need to download and install Xcode 8 beta for this to work. Afterwards they should be available in all applications.
From Sierra onward, they are included in Terminal.app.
Functions
Please see this file.
HardwareBluetoothHarddisksForce Enable Trim
Enable Trim for non-Apple SSDs. This command is available since Yosemite.
![]() Hardware InformationList All Hardware PortsRemaining Battery PercentageRemaining Battery TimeShow Connected Device's UDIDShow Current Screen ResolutionShow CPU Brand StringInfrared ReceiverPower ManagementPrevent System Sleep
Prevent sleep for 1 hour:
Show All Power Management SettingsPut Display to Sleep after 15 Minutes of InactivityPut Computer to Sleep after 30 Minutes of InactivityCheck System Sleep Idle TimeSet System Sleep Idle Time to 60 MinutesTurn Off System Sleep CompletelyAutomatic Restart on System FreezeChime When Charging
Play iOS charging sound when MagSafe is connected.
Input DevicesKeyboardAuto-CorrectFull Keyboard Access
Enable Tab in modal dialogs.
Key Repeat
Disable the default 'press and hold' behavior.
Key Repeat Rate
Sets a very fast repeat rate, adjust to taste.
LaunchpadReset Launchpad Layout
You need to restart
Dock because Launchpad is tied to it.
MediaAudioConvert Audio File to iPhone RingtoneCreate Audiobook From Text
Uses 'Alex' voice, a plain UTF-8 encoded text file for input and AAC output.
Disable Sound Effects on BootMute Audio OutputSet Audio VolumePlay Audio File
You can play all audio formats that are natively supported by QuickTime.
Speak Text with System Default VoiceVideoAuto-Play Videos in QuickTime PlayerNetworkingBonjourBonjour ServiceDHCPRenew DHCP LeaseShow DHCP InfoDNSClear DNS CacheHostnameSet Computer Name/Host NameNetwork PreferencesNetwork Locations
Switch between network locations created in the Network preference pane.
Set Static IP AddressNetworking ToolsPing a Host to See Whether It’s AvailableTroubleshoot Routing ProblemsSSHPermanently Add Private Key Passphrase to SSH Agent
Prior to macOS Sierra, ssh would present a dialog asking for your passphrase and would offer the option to store it into the keychain. This UI was deprecated some time ago and has been removed.
Instead, a new UseKeychain option was introduced in macOS Sierra allowing users to specify whether they would like for the passphrase to be stored in the keychain. This option was enabled by default on macOS Sierra, which caused all passphrases to be stored in the keychain.
This was not the intended default behavior, so this has been changed in macOS 10.12.2. (Source)
Then add to
~/.ssh/config :
Remote LoginTCP/IPShow Application Using a Certain Port
This outputs all applications currently using port 80.
Show External IP Address
Works if your ISP doesn't replace DNS requests (which it shouldn't).
Alternative that works on all networks.
Show Network Interface Information
Undocumented flag of the
scutil command.
TFTPStart Native TFTP Daemon
Files will be served from
/private/tftpboot .
Wi-FiJoin a Wi-Fi NetworkScan Available Access Points
Create a symbolic link to the airport command for easy access:
Run a wireless scan:
Show Current SSIDShow Local IP AddressShow Wi-Fi Connection HistoryShow Wi-Fi Network Passwords
Exchange SSID with the SSID of the access point you wish to query the password from.
Turn on Wi-Fi AdapterPackage Managers
HomebrewFull UninstallPrintingClear Print QueueExpand Print Panel by DefaultQuit Printer App After Print Jobs CompleteSecurityApplication FirewallFirewall ServiceAdd Application to FirewallGatekeeperAdd Gatekeeper ExceptionRemove Gatekeeper ExceptionManage GatekeeperPasswordsGenerate Secure Password and Copy to ClipboardPhysical AccessLaunch Screen SaverLock ScreenScreensaver Immediate LockScreensaver PasswordWiping Data
Note: The
srm command appears to have been removed on MacOS after 10.9. There is a note on an Apple support page hinting as to why:
With an SSD drive, Secure Erase and Erasing Free Space are not available in Disk Utility. These options are not needed for an SSD drive because a standard erase makes it difficult to recover data from an SSD.
Securely Remove FileSecurely Remove FolderSecurely Remove Path (Force)SearchFindRecursively Delete .DS_Store FilesLocateBuild Locate DatabaseSearch via Locate
The
-i modifier makes the search case insensitive.
SystemAirDropAppleScriptExecute AppleScriptBasicsCompare Two FoldersCopy Large File with Progress
Make sure you have
pv installed and replace /dev/rdisk2 with the appropriate write device or file.
Restore Sane Shell
In case your shell session went insane (some script or application turned it into a garbled mess).
RestartShutdownShow Build Number of OSUptime
How long since your last restart.
ClipboardCopy data to ClipboardConvert Clipboard to Plain TextConvert Tabs to Spaces for Clipboard ContentCopy data from ClipboardSort and Strip Duplicate Lines from Clipboard ContentFileVaultAutomatically Unlock FileVault on Restart
If FileVault is enabled on the current volume, it restarts the system, bypassing the initial unlock. The command may not work on all systems.
FileVault ServiceInformation/ReportsGenerate Advanced System and Performance ReportInstall OSCreate Bootable Installer
Kernel ExtensionsDisplay Status of Loaded Kernel ExtensionsLoad Kernel ExtensionUnload Kernel ExtensionsLaunchAgents
Please see this file.
LaunchServicesRebuild LaunchServices Database
To be independent of OS X version, this relies on
locate to find lsregister . If you do not have your locate database built yet, do it.
Login WindowSet Login Window TextMemory ManagementPurge memory cacheShow Memory StatisticsNotification CenterNotification Center ServiceQuickLookPreview via QuickLookRemote Apple EventsRoot UserSafe Mode BootSave Dialogs
Significantly improve the now rather slow animation in save dialogs.
ScreenshotsTake Delayed Screenshot
Takes a screenshot as JPEG after 3 seconds and displays in Preview.
Save Screenshots to Given Location
Sets location to
~/Desktop .
Save Screenshots in Given Format
Sets format to
png . Other options are bmp , gif , jpg , jpeg , pdf , tiff .
Disable Shadow in ScreenshotsSet Default Screenshot Name
Date and time remain unchanged.
Software InstallationInstall PKGSoftware UpdateInstall All Available Software UpdatesSet Software Update Check Interval
Set to check daily instead of weekly.
Show Available Software UpdatesSet Software Update Server
This should only be done for testing purposes or unmanaged clients. To use network-wide, either correctly set up DNS along with Apple SUS service and bind your clients via OpenDirectory. Alternatively, use Reposado together with correct network DNS settings to make resolution transparent. Margarita looks nice to have as well.
Software VersionShow System Software VersionSpotlightSpotlight IndexingErase Spotlight Index and RebuildSearch via SpotlightShow Spotlight Indexed MetadataSystem Integrity ProtectionDisable System Integrity Protection
Reboot while holding Cmd + R, open the Terminal application and enter:
Enable System Integrity Protection
Reboot while holding Cmd + R, open the Terminal application and enter:
Date and TimeList Available TimezonesSet TimezoneSet Clock Using Network TimeTerminalRing Terminal Bell
Rings the terminal bell (if enabled) and puts a badge on it.
Alternative TerminalsMac Terminal Directory Commands
ShellsBash
Install the latest version and set as current user's default shell:
fish
Install the latest version and set as current user's default shell:
Zsh
Install the latest version and set as current user's default shell:
Terminal Fonts
GlossaryMac OS X, OS X, and macOS Version Information
LicenseThis work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Active1 year, 1 month ago
I want to open videos and pictures from Terminal. https://treetribal320.weebly.com/blog/better-program-than-itunes-for-mac. Is there any way to do this?
Timothy Mueller-Harder
10.4k1717 gold badges6262 silver badges117117 bronze badges
Abhimanyu AryanAbhimanyu Aryan
94077 gold badges2020 silver badges3535 bronze badges
3 Answers
To open any file from the command line with the default application, just type
open followed by the filename/path.
Example:
Edit: as per Johnny Drama's comment below, if you want to be able to open files in a certain application, put
-a followed by the application's name in quotes between open and the file.
Example:
If you need further information about the Timothy Mueller-HarderTimothy Mueller-Harder
open command, type man open .
10.4k1717 gold badges6262 silver badges117117 bronze badges
It can also be done by using nohillside♦
xdg-open filename .Command will open the file with it's default application and it also used to open the urls .
57k1414 gold badges120120 silver badges168168 bronze badges
Dev Pratap SinghDev Pratap Singh
Fun Mac Terminal Commands
Developer MadmaxDeveloper Madmax
You must log in to answer this question.Program Command For Mac Terminalprotected by MarkJul 15 '18 at 19:04Commands For Mac Terminal
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead? Not the answer you're looking for? Browse other questions tagged terminalcommand-line .Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |