Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Reply to this topicStart new topic
> Switching Users In A Script, scripts
post Sep 28 2003, 12:48 AM
Post #1

Whats this Lie-nix Thing?

Group: Members
Posts: 1
Joined: 28-September 03
Member No.: 1,539


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!
Go to the top of the page
+Quote Post
post Sep 28 2003, 07:13 AM
Post #2

Its GNU/

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151

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.

Johnny Hughes
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 22nd July 2018 - 01:43 PM