"su - lfs" vs "su lfs" - su starts subshell, useless for automating in scripts..

Dan Nicholson dbn.lists at gmail.com
Tue Nov 27 14:21:44 PST 2007

On Nov 26, 2007 10:55 PM, armencho at gmail.com <armencho at gmail.com> wrote:
> One of the things i find difficult to script is a "nice" (read pretty)
> way of continuing the install script after doing "su - lfs". the 'su'
> command apparently starts a subshell process, and so the new subshell
> just waits for user action, pausing the whole install script that
> started the 'su'. And I cannot make it continue with the script as the
> 'lfs' user, since, well su just blocks, and that is the way it works.

Read the man page for su. It only drops you to a shell if you don't
give it a command to use. Try this:

su - -c "/path/to/some_script.sh" lfs

Beware that where you place the user on the command line is touchy
depending on who's su you're using. Also, since you're not dropping to
a shell, you won't pick the .bash* files created for the lfs user, so
you'll have to recreate that environment somehow.


More information about the lfs-support mailing list