login as root but run script as guest

Nemesis related tutorials and docs
Forum rules
Please only post tutorials and HOWTOs in here. It should not be a discussion area.
Locked
User avatar
francois
Contributor
Contributor
Posts: 5369
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

login as root but run script as guest

Post#1 by francois » 14 Dec 2015, 23:32

I am working in root mode. I would like to create a script to start chromium as user guest, from one command line if possible without having to issue the password for guest. Is this possible?
Prendre son temps, profiter de celui qui passe.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5867
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: starting package with a script for user guest

Post#2 by brokenman » 15 Dec 2015, 01:40

Code: Select all

su - guest -c chromium
How do i become super user?
Wear your underpants on the outside and put on a cape.

aus9

Re: starting package with a script for user guest

Post#3 by aus9 » 15 Dec 2015, 03:53

su - guest -c chromium
I am not sure if that will work but in a test of mtpaint I changed to root and then ran

Code: Select all

su -c guest mtpaint 
su: user mtpaint does not exist
but this does work

Code: Select all

su -c mtpaint guest

so as I don't have chromium installed I would suggest

Code: Select all

su -c chromium guest

User avatar
francois
Contributor
Contributor
Posts: 5369
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: starting package with a script for user guest

Post#4 by francois » 15 Dec 2015, 04:07

aus9, you have the winning combination.

Thanks to both of you.
Prendre son temps, profiter de celui qui passe.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5867
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: starting package with a script for user guest

Post#5 by brokenman » 15 Dec 2015, 12:37

Sorry mixed the order. The correct aproach would be:

Code: Select all

su guest - -c mtpaint
su guest -
Starts a login shell for guest with guest environment.

-c command
Runs a command for su
How do i become super user?
Wear your underpants on the outside and put on a cape.

Locked