|
Home > Wiki > Mac Articles
All articles are licensed under CC0 1.0 making them public domain.
Sleep behaviour #
Last updated 8 February 2026
Sometimes you need your Mac to stay awake to complete a long task like compiling or transferring data.
Screen off, still running
Keyboard shortcut to lock your Mac, turn off the screen and continue running:
⌘ + control + q
Screen on, still running
This command won't let your mac sleep until you control + c the terminal. Open a terminal and type:
caffeinate -disu
Keeping track of launch agents #
Last updated 9 February 2026
Launch agents are programs which automatically start on macOS, they can be viewed and disabled in System Settings (on macOS 13 Ventura and higher) but cannot be deleted. Applications are able to add launch agents at will, commonly auto updaters or network related daemons. Note that these differ from "Login Items" which are usually for user-facing applications. They can be found as plist files in the following locations:
/Library/LaunchAgents
/Library/LaunchDaemons
~/Library/LaunchAgents
Clean-up Script
I have written a script called agentlookout that when ran cleans up your launch agents/daemons by removing ones not whitelisted. It's a simple script that I recommend running once a while and especially after launching Chrome and any Adobe products. I recommend reading App Specific Notes in the script's documentation before removing any launch agents.
Delete .DS_Store #
Last updated 9 February 2026
.DS_Store is a file on Mac that Finder places within directories in order to store directory specific prefernces. It serves a purpose and is mostly harmless but sometimes you need to delete all of them within a directory. This is a quick one liner to do that:
find . -name ".DS_Store" -type f -delete
For a more permanant and reliable solution try excluding .DS_Store with the tool you are using to archive or transfer files.
Reset Launchpad layout #
Last updated 8 February 2026
Launchpad gets messy, this command resets the layout. You may need to open Launchpad two times before all icons display again. Enter in a terminal:
defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock
macOS 15.2 Sequoia
As discussed in this MacRumors forum post, the command no longer works on macOS 15.2 Sequoia and onwards, now the following is recommended:
sudo find 2>/dev/null /private/var/folders/ -type d -name com.apple.dock.launchpad \
-exec rm -rf {} +; killall Dock
Running macOS as a VM guest with VirtualBox #
Last updated February 2021
This has been tested with OS X Snow Leopard as a guest.
- Confirm that EFI is enabled in the VM settings, if you select the default OS X template within VirtualBox then this will already be configured.
- Enter the commands contained in this text file into your terminal.
- Boot the VM and you should be loaded into the EFI shell.
- Type
exit in the shell.
- Choose
Boot Maintenance Manager, then Boot From File.
- Select the entry listing
HFS+, then navigate through the file hierarchy like so: System/Library/CoreServices/boot.efi.
- Once you've found
boot.efi, press return to boot the installer.
Problems
- To my knowledge no graphic drivers are available, therefore the resolution is locked and most advanced apps don't work:
- None of the apps in iWork '06 work
- Most of the apps in iLife '08 don't work, with the exception of iPhoto and Garageband
Sources
- The VirtualBox settings come from soupbowl.io.
- The EFI shell tip comes from Ahmad Uzair from a SuperUser question.
Server: Starting and stopping launch daemons #
Last updated 9 February 2026
Launch daemons are script files that are managed by the system which have versatile options for running them, the system tracks "loaded" daemons as to avoid running duplicates. They are located at /Library/LaunchDaemons/.
Starting one-time
sudo launchctl load /Library/LaunchDaemons/com.example.daemon.plist
Stopping one-time
sudo launchctl unload /Library/LaunchDaemons/com.example.daemon.plist
Server: Writing launch daemons #
Last updated 9 February 2026
Here's an example txt file named /Library/LaunchDaemons/com.webserver.daemon.plist. The following explains the keys:
| Key Name |
Description |
Label |
Name of the daemon. |
ProgramArguments |
Command and arguments to call. |
EnvironmentVariables |
Optional list of environment variables used when running the program, PATH key and value may be needed to run some scripts. |
RunAtLoad |
Run when the user logs in, most likely wanted. |
WorkingDirectory |
Directory to execute from. |
UserName |
Name of existing user account to run the program as. |
StandardOutPath |
Optional log file, I recommend configuring one. |
StandardErrorPath |
Optional error log file, I recommend configuring one. |
Logging
I recommend configuring logging by setting both StandardOutPath and StandardErrorPath. The most Unix-like option is using /var/log though you will need to configure file ownership before running the service.
Server: Creating daemon users #
Last updated February 2021
Daemon users are usually used alongside launch daemons. Find out what they are and how to create them.
In this example a daemon user named _webserver is created. Make sure you replace this with your own new daemon username.
- Decide on a name for your user and prefix with an underscore, this will also be the name for a new group the user will be a member of. For example
_webserver.
- In a terminal, enter interactive user mode:
~ $ sudo dscl
Entering interactive mode... (type "help" for commands)
>
- Move to the base folder:
> cd /Local/Default/
- List all groups and find an unused GID preferably less than 500:
/Local/Default > ls Groups gid
- Create a group and assign the GID found in the previous step, in this example the GID found is 300 but it may differ for you:
/Local/Default > create Groups/_webserver
/Local/Default > create Groups/_webserver PrimaryGroupID 300
- List all users and find an unused UID preferably less than 500, this can be different to your GID:
/Local/Default > ls Users uid
- Create a user and assign the UID found in the previous step, in this example the UID found is 300 but it may differ for you:
/Local/Default > create Users/_webserver UserShell /bin/bash
/Local/Default > create Users/_webserver UniqueID 300
- Set the user's group ID to the GID previously found and assigned to the group, alongside this also set the user's home directory:
/Local/Default > create Users/_webserver PrimaryGroupID 300
/Local/Default > create Users/_webserver NFSHomeDirectory /Users/_webserver
- Add the user to the previously created group:
/Local/Default > append Groups/_webserver GroupMembership _webserver
- Exit out of interactive user mode:
/Local/Default > exit
Goodbye
- Run these two commands to remove the user from the user-facing login screen:
sudo dscl . delete /Users/_webserver AuthenticationAuthority
sudo dscl . create /Users/_webserver Password "*"
- Create the user's home directory and set the correct permissions:
sudo mkdir /Users/_webserver
sudo chown _webserver:_webserver /Users/_webserver
- This user is now created and can be used within launch daemons.
Instructions distilled from a similar document in the Minecraft Wiki
Server: Nginx configuration file location #
Last updated 8 February 2026
With a standard Homebrew install it is located at:
/usr/local/etc/nginx/nginx.conf on Intel (with -rw-r--r-- USER:admin permissions).
/opt/homebrew/etc/nginx/nginx.conf on Apple Silicon
|