It is not known to everyone, but the macOS login screen can be customized in various ways. You can show particular indications, details on the machine and even recall … secret commands.
12 Tricks For The macOS Login Screen
The macOS login screen, the one that is normally shown at system startup (you can disable it by setting the automatic login), allows you not only to specify your login credentials, show the stop buttons, restart and shut down, and more but hides various secrets.
The Twocanoes developers have published on their site a complete list of features that can be called up from the login screen, all working even with macOS 10.14 Mojave and that we propose below.
Change the Switch mode between icon and user name and password fields
By default macOS proposes to the login the screen that requires the entry of the password listing the users with their icon. By pressing the Option-Enter key combination it is possible to change on the fly by choosing between icon with password and manual indication of user name and password.
Secret commands
Instead of manually specifying the user name it is possible to specify secret commands in the login window (they all start with the “>” character). To turn off your Mac, just type:
> power
To restart your Mac:
> restart
To shut down the computer:
> shutdown
To activate the stop:
> sleep
To return to the login window
> exit
View useful information before login
Apart from the possibility of choosing the user, typing the password and pressing the Stop, Restart and Shutdown buttons, macOS does not offer the possibility of showing other information. A little trick lets you view some details in the login window that might be useful in some cases.
For example, it is possible to display a personalized text, opening the Terminal and typing (all on one line) the following command followed by the back key and the administrator password.
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText
Instead of the text in quotation marks you can obviously indicate anything (eg “The owner of this computer is Mario Rossi”, useful in case of theft, or, in an office with multiple computers, the name, phone number or email from the technical manager).
To restore the normal default setting just write:
sudo defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText
Show IP address, macOS version and computer name
Along the lines of the previous trick, you can show details such as the IP address, the version of OS X installed and the name of the computer, by clicking several times at the top right (on the clock) by typing the command in the Terminal:
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
To restore the default setting, just write:
sudo defaults delete /Library/Preferences/com.apple.loginwindow AdminHostInfo
or, alternatively, delete the “com.apple.loginwindow” file.
Log in with a PIN instead of the password
macOS integrates standard support for various smart cards and for the YubiKey (USB flash drive which is a valid alternative to two-factor authentication mechanisms). If you use a YubiKey you can pair it to authenticate the user account of macOS. At the next login, just insert the key and log in using the PIN.
Show the login window with FileVault encryption active
If you have activated the “FileVault” option in the relevant section of MacOS “Security and Privacy” Preferences, at the start you must specify the password to unlock the disk and the login window does not appear. Instead of automatically logging in, you can show the login window by typing this command in the Terminal:
sudo defaults write /Library/Preferences/com.apple.loginwindow DisableFDEAutologin -bool YES
Hide some buttons
By selecting the “Users and Groups” section in the System Preferences, you can click on “Login Options”, activate the changes (click on the padlock) and decide whether to log in automatically or not, show the login window as a list of users or name and password, show or hide the Stop, Restart, Turn off buttons. If you want to disable only some buttons, just use the following Terminal commands:
sudo defaults write /Library/Preferences/com.apple.loginwindow ShutDownDisabled -bool true
sudo defaults write /Library/Preferences/com.apple.loginwindow RestartDisabled -bool true
sudo defaults write /Library/Preferences/com.apple.loginwindow SleepDisabled -bool true
To restore the commands:
sudo defaults write /Library/Preferences/com.apple.loginwindow ShutDownDisabled -bool false
sudo defaults write /Library/Preferences/com.apple.loginwindow RestartDisabled -bool false
sudo defaults write /Library/Preferences/com.apple.loginwindow SleepDisabled
Run a script
It is possible to automatically start a script at each login, executing a command from Terminal and specifying the relative path.
sudo defaults write com.apple.loginwindow LoginHook / path / to / script
It is, for example, possible to exploit Zapier (a web app that allows you to automate an application starting from events that occur in other applications), and send a notification to an iOS device whenever someone logs in to our computer. In the following example, $ 1 is the short name of the user logging in, and $ HOSTNAME is the computer name.
#! / Bin / sh
curl “https://hooks.zapier.com/hooks/catch/8675/309/?name=$1&computer=$HOSTNAME”
After this command, whenever someone logs in to the computer, a notification will be shown on our iOS device.
Activate / deactivate the keyboard
If you need to show the virtual keyboard of macOS also in the login window, you can activate it by opening the System Preferences, selecting “Users and groups”, clicking on “Login Options”, enabling the changes (click on the lock ) and choosing the option “Show keyboard menu in the login window”.
Machine use policy and other notices in the login window
You can set custom alerts to be displayed in the login window on the Mac. A warning of this type is displayed in the login window and requires a confirmation from the user before proceeding.
This feature allows you to set an alert in the login window to display a long message that must be accepted before you can log in. This type of alert can be useful when users need to agree to terms or conditions (for example, usage policies) before they can use the computer. Below is how to create an alert
- Create a text-only document (.txt) or RTF (.rtf) containing the warning.
- Choose File> Save, specifying “PolicyBanner” (without quotes) as the document name.
- Copy the PolicyBanner file to the / Library / Security / folder.
- The next time the computer is restarted, the warning is displayed when the login screen normally appears.
If you have FileVault active, the alert is displayed after the first user logs in, before the desktop appears (the first access is to unlock the boot disk).