Tag: terminal
-
Terminal Secure Keyboard Entry and sudo with Touch ID on macOS
At one point or another, you may have discovered that you can enable Touch ID for sudo in the macOS terminal. You used to have to manually edit the /etc/pam.d/sudo file after every macOS update to re-enable it, but now you can keep it enabled permanently. When you have Touch ID enabled for sudo, you…
-
Terminal command to tell if a macOS directory is SIP-protected
Starting with El Capitan (OS X 10.11), Apple started using System Integrity Protection (SIP) in macOS, so that certain directories would be not writable, even by root. Here’s a quick reference for a couple of commands you can use to see if a directory or file is SIP-protected, as that may change from macOS version…
-
macOS command to add back Wi-Fi service
Acknowledgements: Hat tip to Eric Hemmeter on the MacAdmins Slack for this command. If you want a command that will add back the Wi-Fi service if you deleted it and now want it back, here it is: networksetup -createnetworkservice Wi-Fi en1 That’s assuming the output of networksetup -listallhardwareports has a hardware port of Wi-Fi with…
-
Terminal command to see the Startup Disk in macOS
If you want to see what the current Startup Disk is on your macOS installation, you can certainly go to System Preferences > Startup Disk. But if you want to use the terminal instead of the GUI, this command will return the current Startup Disk: bless –getBoot If a Startup Disk is set, you’ll see…
-
Changing the CrashPlan primary server by terminal commands on a Mac
We recently wanted to change the primary server for our CrashPlan clients from an IP-based one to a DNS-based one. Unfortunately, CrashPlan doesn’t have a .plist file you can just run a defaults write command on. So apart from going into every machine and manually changing it from the menu bar, there is a way…
-
Terminal command to get the full name of a Mac user
Munki-Enroll is a great little script combo that automatically changes the ClientIdentifier for Munki clients and then automatically creates a corresponding manifest on the Munki server that includes the old manifest. I wanted to tweak it quite a bit to fit some of the quirks of how our organization does Munki client manifests, so I…
-
Scripting enabling root or disabling root on Mac OS X
If you want to script enabling or disabling the root account in Mac OS X (instead of having to go to Directory Utility to do it), you’ll want to use the dsenableroot command. Enable the root user dsenableroot -u adminaccount -p adminaccountpassword -r rootpasswordyouwant Disable the root user dsenableroot -d -u adminaccount -p adminaccountpassword Important…
-
Enable SSH for only one user via command line
If you want to enable SSH for only one user using the command line on a Mac, run these three commands: Make sure the group exists sudo /usr/sbin/dseditgroup -o create -q com.apple.access_ssh Add user username to the group sudo /usr/sbin/dseditgroup -o edit -a username -t user com.apple.access_ssh Turn remote login on sudo /usr/sbin/systemsetup -setremotelogin on…
-
Filling out a Google Form from the terminal using the curl command
Cheating a bit here by just linking to someone else’s blog post, but it’s very well written, with screenshots and different colors. Why reinvent the wheel? Here it is: Submit Google Forms By Curl Command
-
Toggle Allow apps downloaded from anywhere
There’s a setting on Mac OS X for allowing apps to be installed from anywhere or only from signed developers. If you want to automate changing this setting via terminal command, this is how you do it. sudo spctl master-enable sudo spctl master-disable The spctl command is even more versatile than that. More details at…
-
Using a terminal command to disable App Store automatic checks
If you want to automate disabling the App Store auto check, the terminal equivalent of System Preferences > App Store > Automatically check for updates is sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool false This is handy to know in case you’re managing updates a different way (e.g., Munki) and don’t want your users pestered with…
-
Enable duplex printing via terminal command on a Mac
If you want to enable duplex printing via a terminal command (e.g., trying to fix a bunch of already-installed printers with duplex disabled, and you want to fix that with a script), first you have to figure out what parameter to change. On one Mac with the printer installed, find the printer via System Preferences…
-
Renaming a Mac hard drive from the command line
You know, if your hard drives are set to show as icons on the desktop, you can rename them by selecting them, hitting Enter, and then typing in a new name? If you want to script naming, you can also name from the command line. For example, if you want to rename the drive you’re…
-
Modifying the Energy Saver “Put hard disks to sleep when possible” setting using the terminal
If you’re looking in Yosemite for where the Put hard disks to sleep when possible setting in Energy Saver lives, it’s in /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist, so you can view with the command defaults read /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist and you’ll see the value in “Disk Sleep Timer”, with 10 meaning the box is checked and 0 meaning it’s not checked.…
-
Modifying the Energy Saver “Turn display off after” preferences in Yosemite using the terminal
What’s the problem? I’m shocked at how little straightforward documentation there is regarding where the Energy Saver settings (from System Preferences) are stored or how to modify them using the terminal. Where are the settings stored? Using opensnoop, I was able to track down that Energy Saver modifies this file: /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist The main slider in…