These notes are for my personal use and since I don’t own or really use a Mac, they may not be too useful for anyone else. One important methodology is logging in remotely and troubleshooting the misbehaving Macs of users.
What Version Of OSX Is This Running
This is very handy for many reasons:
someguysmac:~ xed$ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: Mac OS X 10.6.8 (10K549)
Kernel Version: Darwin 10.8.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: mablab
User Name: Chris X Edwards (xed)
Secure Virtual Memory: Not Enabled
64-bit Kernel and Extensions: No
Time since boot: 4 days 21:55
What terrifying animal does something like "10.6.8" refer to? Look at the OS_X Wikipedia article to find out. 10.6 is Snow Leopard for example.
Updating From Command Line
I sometimes have to log in to a Mac over SSH and update it. Here’s how to check the status of things.
softwareupdate -l
And then to actually install all updates.
sudo softwareupdate --verbose --install --all
Or --recommended
for just the recommended ones. (Why would some not be
recommended?!) Or --os-only
, etc — see the --help
.
Interesting
The say
command looks fun.
The screencapture
reminds me of import
.
For opening Word files and so on, use open <filename>
. Which version
of Word if you have two? I don’t know how it knows but it seems to go
for the latest.
Here’s a collection of similar tips for using the Mac OS X command line to best effect.
Creating Users From Command Line
Sometimes I need to use an appley computer and I’m given some credentials. To avoid ickiness, I’ll want to create my own proper account immediately after logging in. Remotely. I will be logging in remotely. Even if the machine is just sitting right next to me. Anyway, I think this does the job.
sudo sysadminctl -addUser xed -fullName "aescape@xed.ch" -UID 11111 \
-shell /bin/bash -password - -home /Users/xed
sudo mkdir /Users/xed
sudo chown 11111:staff /Users/xed
sudo dscl . append /Groups/admin GroupMembership xed
It seems the default group for normal user creation is staff
.
I don’t know about including -GID 11111
; I did notice
that when I tried -GID 11111
it then produces a 11111
as one of
the group names specified by the groups
command.
Apple Suicide Prevention
You tell someone at the data center to turn on your Mac, you log in and are happily doing appley things when (about 5 minutes later) suddenly nothing works. Exactly like this thread implies. Unfortunately that thread is just ignored and everyone just can’t believe the problem is real - but it is! Well, maybe there is a lag as the system wakes up or whatever, but I’ve had my SSH session freeze from this. Ah yes, looks like it’s frozen but it wakes up after about 5s-10s or something very long.
Here are a couple of things to look into.
man caffeinate
This will set "assertions" that apparently are honored by the power management system. By using this you can assert that power stay on or off, etc, pretty much like moving the mouse will assert that. That’s the theory.
The other one seems to be a more fundamental tool.
man pmset
I don’t know what the answer is but its something related to these commands.
Xcode
Pretty much nothing sensible can happen on an Apple device until you
install Apple’s developer tools known as
Xcode. I found on a Mavericks OS X
(10.9, I think) in 2014 when it was the latest and greatest that I was
able to install Xcode by simply opening a terminal and typing gcc
.
Since the Gnu Comipler Collection was missing, a fancy GUI box opened
and asked if I wanted Xcode to automagically be installed. This still
worked the same way in 2022 with "Monterey", perhaps because the EULA
was dated from 2016 - no singularity here!
Note that it took a pretty long time to install this even on the fastest connection possible. Ah, the miracle of single point of failure.
Here’s a fun message I got with brew
(see below) that might be good
to preclude at this stage.
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.4.
Homebrew
It is not strictly necessary, but when exploring Unix on a Mac, the experience is enhanced by having all resources available installed. After Xcode is successfully installed, the next thing to have to make your Apple system really useful is Homebrew which is a package manager for Macs that make installing the things Apple neglected to quite easy. Just go to the Homebrew page and cut and paste the line they show for "Install Homebrew". Something like this
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After providing your system password one or many times, it’s ready to
go. All the stuff looks to be dumped into /opt/homebrew
, but only
the ghost of Steve Jobs knows what really happens. The executable is
hiding in /opt/homebrew/bin/brew
so you might want to symlink that
to somewhere sensible or put that mess in your $PATH
if you’re
brave.
Then you can do
things like brew install wget
to install the very useful program
wget
.
You might want to do something like this to pretend you didn’t already sell your soul.
export HOMEBREW_NO_ANALYTICS=1
Here are some typical brew
operations.
brew update
brew upgrade
brew info gcc
brew install gcc
brew cleanup
Here are a few of my favorite free software packages that
Apple should have included, but didn’t, which you can get with brew
:
mercurial, cvs, source-highlight, imagemagick, asciidoc.
An interesting thing is that when you install packages it creates a symlink in
your /Users/xed/bin/
directory. I have one of these even on Linux
systems so I approve. This means that after installing a sane Bash,
(whoops hang on - you need to add /Users/xed/bin/bash
to
/etc/shells
for it to be considered valid) you can chsh -s
/Users/xed/bin/bash xed
.
Other Software
Getting serious about Python packages? You might need to do this.
python3 -m pip install --upgrade pip
Display Ports
I just noticed that some new (2014) Apples have an HDMI port. A normal regular HDMI port. Just to keep things interesting, there’s of course the Apple magical display port also. So much for space saving.
Possible display options for Intel-based Mac laptops to VGA:
micro-DVI to VGA |
MacBook Air (Early 2008) |
mini-DVI to VGA |
MacBook (13-inch, Mid 2009) |
MacBook (13-inch, Early 2009) |
|
MacBook (13-inch, Late 2008) |
|
MacBook (13-inch, Early 2008) |
|
MacBook (13-inch, Late 2007) |
|
MacBook (13-inch, Mid 2007), |
|
MacBook (13-inch, Late 2006) |
|
MacBook (13-inch) |
|
DVI to VGA |
MacBook Pro (17-inch, Late 2008) |
MacBook Pro (17-inch, Early 2008) |
|
MacBook Pro (15-inch, Early 2008) |
|
MacBook Pro (17-inch, 2.4 GHz, Late 2007) |
|
MacBook Pro (15-inch, 2.4/2.2 GHz) |
|
MacBook Pro (15-inch, Core 2 Duo) |
|
MacBook Pro (17-inch, Core 2 Duo) |
|
MacBook Pro (15-inch, Glossy) |
|
MacBook Pro (15-inch) |
|
MacBook Pro (17-inch) |
|
mini-DisplayPort to VGA |
MacBook Pro (Retina, 13-inch, Late 2012 and later) |
MacBook Pro (Retina, 15-inch, Early 2013 and later) |
|
MacBook Pro (Retina, Mid 2012) |
|
MacBook Pro (13-inch, Mid 2009 and later) |
|
MacBook Pro (15-inch, Late 2008 and later) |
|
MacBook Pro (17-inch, Early 2009 and later) |
|
MacBook (13-inch, Late 2009 and later) |
|
MacBook (13-inch, Aluminum, Late 2008) |
|
MacBook Air (Late 2008 and later) |