Linux - Log out of Unity or Gnome from Command Line Terminal
To log out of Gnome or Unity from the command line, simply run this command:
It will prompt you to click the 'log out' button. To log out without being prompted, run this command:
This should work in any Linux distribution (Ubuntu, Debian, openSUSE...) that is using Unity, Gnome, or a Gnome based desktop environment.