Register
It is currently Sat Aug 30, 2014 2:23 am

Exit user in bash script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Sat Oct 12, 2013 9:42 pm   

Joined: Sat Oct 12, 2013 9:40 pm
Posts: 2
I'm writing a bunch of scripts to automatically configure Ubuntu and I want to run the code below to remove the white dots from the login screen:

Code:
sudo xhost +SI:localuser:lightdm
sudo su lightdm -s /bin/bash
gsettings set com.canonical.unity-greeter draw-grid false


The problem is that as soon as this code is executed, it stays logged in as lightdm and the rest of the script doesn't run. I've tried to change the last command to this:

Code:
echo "exit" | gsettings set com.canonical.unity-greeter draw-grid false


but this doesn't seem to work and my script still stops running.

Is any one able to let me know where I'm going wrong?

My scripts can be found here:
github.com/maerlyngb/UbuntuCinnamonSetupScripts


Top
 Profile  
 PostPosted: Sun Oct 13, 2013 3:27 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 535
hi,

this way:
Code:
sudo xhost +SI:localuser:lightdm
sudo su lightdm -s /bin/bash -c 'gsettings set com.canonical.unity-greeter draw-grid false'

I'm not sure ``sudo su'' is a good idea; that seems strange imo.
``sudo'' can be used to execute command in place of another user.


Top
 Profile  
 PostPosted: Sun Oct 13, 2013 5:41 am   

Joined: Sat Oct 12, 2013 9:40 pm
Posts: 2
Thanks for that.

I've only been using linux for a few weeks so I don't know a huge about about bash scripting yet. How would I do this without using sudo su?

tbh I just googled the code for this and each source I found used the sudo su method:
http://desktoplinuxreviews.com/linux-ti ... in-screen/
http://www.noobslab.com/2012/05/remove- ... en-of.html
http://ubuntuportal.com/2013/05/how-to- ... 13-04.html


Top
 Profile  
 PostPosted: Sun Oct 13, 2013 4:09 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 535
Code:
sudo -u <user> -- bash -c '<commands>'


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP