In old versions of gnome the command gnome-screensaver-command -l would lock your screen.
As gnome-screensaver is no more in gnome 3.8 you now have to send a dbus call. I think this is then handled by GDM.
dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock