Fast user switching via commandline

This is quite an undocumented feature, here is how it works:

Show login screen (without logging out):

#!/bin/bash
# Show the login screen (without logging out)
#
# From: www.chipwreck.de

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

Switch current user (replace 501 with the correct UID):

#!/bin/bash
# Switch to another user without logging out - replace 501 with the uid of the user you switch to
#
# From: www.chipwreck.de

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 501

Finder / Toggle visibility of hidden files

Via Shell this way:

#!/bin/bash
# Toggle Finder showing hidden files
#
# From: www.chipwreck.de

value=`defaults read com.apple.finder AppleShowAllFiles`
if [ $value == "TRUE" ]
then
  defaults write com.apple.finder AppleShowAllFiles FALSE
else
  defaults write com.apple.finder AppleShowAllFiles TRUE
fi
	
killall Finder
exit 0