Unix Resources

Man Pagez or Man Pages

Elevated Shell Shell as actual root user sudo su.

Alternatively, sudo -s gives you elevated permissions but your home is still your home. If you just want to change to an admin user in Terminal type su <admin username>.

Change user in shell: su <any-user-name> useful in Addigy malware clean-up

Spotlight:sudo mdutil -E /  Or, more specifically, sudo mdutil -E /Volumes/[DriveName]

Also try, sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

flush DNS Cache

Turn off Mail preview of attachments – defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes (or false)

Copy only email address in Mail – defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false (or no)

List files in a directory and output the list  to a text file on the hard drive: ls > ~/list-of-files.txt

Disk Usage (this takes a while to run) sudo du -sh /* du man page: https://ss64.com/osx/du.html     Some of my favorite options:

-d depth Display an entry for all files and folders depth folders deep.
-h “Human-readable” output.
-k KB Display block counts in 1024-byte (1-Kbyte) blocks.
-m MB Display block counts in 1048576-byte (1-Mbyte) blocks.
-g GB Display block counts in 1073741824-byte (1-Gbyte) blocks.
-c Display a grand total.

Run Disksweeper as root:

sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper

Display Free Disk Space  df -hT hfs and its Man page: https://ss64.com/osx/df.html

MemTest cd /usr/bin, memtest all, CTRL C.

Enable Disk Utility’s debug menu  defaults write com.apple.DiskUtility DUDebugMenuEnabled 1  (change 1 to 0 to disable the debug menu)

chflags hidden /FilePath or chflags no hidden or SetFile -a V filename.txt or use a .

Clear font caches and databases: sudo atsutil databases -remove or get FontNuke

Diff lets you compare files or folders, diff file-1 file-2 or diff -rq folder-1 folder-2. Example, diff -rq [path to folder 1] [path to folder 2] > ~/Desktop/comparison.txt

This command will provide a nice list of files that occur in dirA but not in dirB, files that occur in dirB, but not in dirA, and files that differ between dirA and dirB. Pipe the output through grep to remove mention of uninteresting files, and sort to tidy it up, e.g.:
diff -qr dirA dirB | grep -v -e ‘DS_Store’ -e ‘Thumbs’ |
sort > diffs.txt

List of Defaults commands

MacAdmins’ favorites

touch ~/timestamp and then change some setting and then find -x / -newer ~/timestamp >~/changedfiles.txt” to generate a list of changed files, and store it in your home directory under the name “changedfiles.txt”. One of these changed files should be the settings file you need to locate.

Enter date XXXX and press Return  format: [mm][dd][HHMM][yy]

For installers with expired certs use Terminal to change date to 0201010116 This should work for Lion, Mountain Lion and Mavericks, 10.7, 10.8 and 10.9

Make Install Media examples:Apple support article

Remember that it is 2 dashes, not an em dash

sudo /Applications/Install\ macOS\ Sonoma.app/Contents/Resources/createinstallmedia –volume /Volumes/14

sudo /Applications/Install\ macOS\ Ventura.app/Contents/Resources/createinstallmedia –volume /Volumes/13

sudo /Applications/Install\ macOS\ Monterey.app/Contents/Resources/createinstallmedia –volume /Volumes/12

sudo /Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia –volume /Volumes/11

sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia –volume /Volumes/15

sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia –volume /Volumes/14

sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia –volume /Volumes/13

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia –volume /Volumes/12 –applicationpath /Applications/Install\ macOS\ Sierra.app

sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia –volume /Volumes/MyVolume

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia –volume /Volumes/11 –applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app

sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia –volume /Volumes/10 –applicationpath /Applications/Install\ OS\ X\ Yosemite.app

/createinstallmedia –volume /Volumes/9 –applicationpath /Applications/Install\ OS\ X\ Mavericks.app –nointeraction

Mountain Lion OS X 10.8 http://osxdaily.com/2012/02/17/make-bootable-os-x-10-8-mountain-lion-usb-install-drive/

Lion and Mountain Lion and newer http://www.sallonoroff.co.uk/blog/2015/11/make-a-bootable-usb-drive-with-createinstallmedia/

Leopard and Snow Leopard https://www.macworld.com/article/2023548/dvd-less-snow-leopard-installation-on-older-mac.html

View All Third Party Kernel Extensions kextstat | grep -v com.apple

Unload Kernel Extension sudo kextunload /System/Library/Extensions/ThirdPartyMystery.kext

System Integrity Protection (SIP), aka rootless csrutil enable and csrutil disable

Disable Time Machine local backups: sudo tmutil disablelocal

The application SomeApp.app can’t be opened. Superuser.com Question 898124  chmod +x SomeApp.app/Contents/MacOS/*

Sierra installer payload failed signature check, resolved by checking date and seeing that it was set to the year 2000. Within Terminal I typed ntpdate -u time.apple.com to resolve this issue.

Spotlight commands

Encrypted zip archive zip -ej ~/Desktop/file.zip ~/Desktop/Kitties.JPG

unzip file.zip -d ~/another/folder

Trigger Setup Assistant so you can create a new admin-level account. mount -uw / then rm /var/db/.applesetupdone

rm -rf some_dir r “recursive” -f “force” (suppress confirmation messages)

Disable Gatekeeper sudo spctl –master-disable

defaults write com.apple.DiskUtility DUDebugMenuEnabled 1 and then killall Finder then open Disk Utility, go to the Debug menu and select Show All Partitions

Time Machine tmutil info https://eclecticlight.co/2017/02/16/diagnosing-and-treating-time-machine-problems-in-terminal/

tmutil enable
tmutil disable
tmutil removedestination
tmutil startbackup
tmutil stopbackup
tmutil disablelocal
tmutil enablelocal
tmutil destinationinfo
tmutil listbackups
tmutil setdestination volume_name
tmutil calculatedrift backup_folder

tmutil addexclusion (By default this command is sticky which means the excluded item will be excluded even if it gets moved around on the Mac)
tmutil -p addexclusion ~/Downloads (The -p option makes the exclusion non-sticky)

sudo /usr/sbin/softwareupdate –ignore “macOS Catalina”

Watchman command line options

Watchman plugin names and slugs

Disabling Watchman plugins

Unlock files sudo chflags -R nouchg /PATH/TO/FILE

chflags = change flags on files/folders such as “locked”
-R = recursive or for everything and follow directories within the specified directory
nouchg = means the file can be changed
/PATH/ = of course is the path to the files you want to change.

Details here: https://superuser.com/questions/40749/command-to-unlock-locked-files-on-os-x

Password Protected Zip file

Type zip -er ~/Desktop/desiredfilename.zip and press the Space bar once.
Drag the file or files you want to share into the Terminal window.
Press Enter.
Enter your desired password and confirm it when prompted. Type carefully; you won’t see the characters you’re entering.

Secure document sharing using Wormhole or 1Password sharing.

Auth Restart

authrestart [-inputplist] [-delayminutes number_of_minutes_to_delay] [-verbose]

sudo fdesetup authrestart -delayminutes 1

sudo fdesetup authrestart -delayminutes 0
restarts the system immediately, bypassing the normal initial unlock. Before the restart can occur, you also have to provide the short username and password for a user entitled to unlock FileVault.

You can also use the tool to list users able to unlock FileVault:
sudo fdesetup list
or for more detail, including any iCloud Recovery Record:
sudo fdesetup list -extended

Menubar item for authrestart – https://github.com/dieskim/FilevaultReboot

“
If you’ve ever wished you had tech support I’d highly recommend you consider Tim Hannon of Sound Support & Solutions. I’d been limping along on my own for years, paying attention to articles to try and keep up to date but truthfully, tech for me is just a means to an end. It is not something I love or have an affinity for, so it always comes last on my list. Yet with data security such a huge concern these days, and fraud, phishing and malware getting so sophisticated. I finally hit a wall. My computer got infected with a Bing hijack, which was relatively benign as malware goes but was incredibly cumbersome to deal with and after months of doing work-arounds I finally contacted Tim, based on a recommendation from a friend.
He removed the malware remotely in about 30 seconds. And he did it, as well as quite a bit of other “housekeeping” I was in need of, while keeping up a very easy to understand explanation of what he was doing, and why, as he was doing it.
Long story short, I signed on with Tim for ongoing remote monitoring to catch anything unintended that ends up on my computer, for what I think is a pretty reasonable fee. I also had him help me reconfigure how I was managing my data in preparation for buying my new computer, and he assisted with the data migration process. Tim is very pleasant to work with, an excellent communicator, and happy to customize his services based on my preferences and needs. Everything beyond the remote monitoring service is based on a (prorated) hourly consult fee. Given the stakes of what we’re working and potential consequences, Tim’s services are a great value and I am really glad he is in my corner!

”

Nota Lucas
Business Owner, August 2023

Read more testimonials.