1) Auto-login
That one is tricky. The default is saved in
defaults read /Library/Preferences/com.apple.loginwindow autoLoginUser
But in order to turn it on or off, you need to do it as root.
Set it:
sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser ShortName
Delete it (turn it off):
sudo defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
2) Showing password after screensaver and sleep mode
I've been trying to get that one to work, and I can't
You will see a lot of hints telling you that the answer is
defaults write com.apple.screensaver askForPassword 1
or variations like
defaults -currentHost write com.apple.screensaver askForPassword -int 1
and that should work, because if you turn it off via System Preferences, you will see:
% defaults read com.apple.screensaver
{
askForPassword = 0;
askForPasswordDelay = 0;
tokenRemovalAction = 0;
}
and then if you turn it back on via System Preferences, you will see
% defaults read com.apple.screensaver
{
askForPassword = 1;
askForPasswordDelay = 0;
tokenRemovalAction = 0;
}
BUT if turn it OFF and the quit System Preferences and change the setting using 'defaults write', when I re-launch System Preferences, it does not reflect that change.
I'd really like to know the answer to that one (preferably without osascript, but if there is no other way, I'll accept it).
3) Go to sleep mode after x minutes
Assuming you mean "have the computer go to sleep after x minutes" you want:
sudo pmset sleep 20
You can also use different settings specifically for when you are on battery (for MacBooks):
sudo pmset -b sleep 10
If you want to specify never sleeping when plugged in, use
sudo pmset -c sleep 0
4) Enable screensaver after x minutes
@Daniel's recommendation worked for me:
sudo osascript -e 'tell application "System Events" to set delay interval of screen saver preferences to 30'
You can use 'sudo pmset displaysleep X' to have the display sleep instead of using the screensaver.
Best Answer
While I applaud the effort to learn how to collect these scripts, I would say you might just buy a copy of Apple's Remote Desktop tool.
It has pre-built data collection tools that will collect thousands of data points about each system, periodically get updates and you can run reports against the local database of last known configurations or tick a checkbox to refresh all status and then run the report.
Here is how the interface for what you ask looks:
That tool leverages ssh log in, remote apple events and Apple's own remote management hooks to be extremely flexible and running arbitrary shell scripts, custom packages, remote Apple Scripts as well as performing more direct data collection that is embedded into the OS.
The reports and data collected are all easily printed, copied or exported in tab/comma separated files for ease of re-use.