Help - Search - Members - Calendar
Full Version: Switching Users In A Script
Linuxhelp > Support > Technical Support
l3dx6000
Hi,

anyone know how to switch to a different user in a single script?

ie: If i am logged in a root, can i switch to another user within a script to perform a task.

Problem is I have a database that root cannot dump data out of, but the database user cannot write data to a cdrom.

big catch 22!

thanks for any help!
hughesjr
as root use the command:

su - username - c 'filename-to-script'

to run a script as a different user ... you can also put that command into a script ...

If run from a user other than root, it will prompt for the user's password you are switching to.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.