I am running Ubuntu 14.04 and user name is pandya.
pandya@pandya-desktop:~$ gnome-session-quit
When above command run without being sudo (sudo su
) in terminal, it successfully logs out.
But when running after sudo (as a root),
root@pandya-desktop:/home/pandya# gnome-session-quit
It gives error :
** (gnome-session-quit:3168): WARNING **: Failed to call logout: The name org.gnome.SessionManager was not provided by any .service files
So, because of being root, I tries to running command with sudo -u pandya gnome-session-quit
to run command as a user pandya. But it gives same error.
Then I tries follwing to run as pandya:
root@pandya-desktop:/home/pandya# su pandya
pandya@pandya-desktop:~$ gnome-session-quit
** (gnome-session-quit:3269): WARNING **: Failed to call logout: The name org.gnome.SessionManager was not provided by any .service files
But it gives same error.
Hence, My question is: How to logout as a root? Because I want to put gnome-session-quit
in sctipt which is to be run as root. (I don't want to kill forcefully process but want to normal logout prompt)
Further Specification:-
I have script which is to be run as root.
#! /bin/bash
....command to be executed.....
sudo -u pandya gnome-session-quit
sudo -i -u pandya gnome-session-quit
? The-i
will emulate a terminal exactly like the user will get. – Louis Matthijssen May 05 '14 at 08:54sudo
? There is a difference. – terdon May 05 '14 at 09:31-i
launches a new login shell, it does not give "a terminal exactly like the user would get" (that would be an interactive, non-login shell) but starts a new login shell instance. – terdon May 05 '14 at 09:42