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

Mark W. Zeininger mwzard at optonline.net
Tue Nov 27 04:34:58 PST 2007

-----Original Message-----
>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.

>Why can't the book just silently change user id instead ?
I use sudo.  It is installed on the liveCD so in chapter 4 when I am setting
up a lfs ID, I add:

to the exiting /etc/suders file on the live CD.  Then where ever the lfs ID
needs root access, I use the sudo command:
sudo make install

The NOPASSWD allows sudo to execute without waiting for a password.

>I could alternatively do a 'su -c ./lfs-continue - lfs', essentially
>passing control further via another script, but then again, i also
>have variables that i need the 'lfs' user shell inherit, which I
>create on my own, for different purposes. Things like timeout values,
>etc... (not part of LFS, although the $LFS variable would be nice to
>have exported).
The sudo command is running under the lfs ID, so any variables set are

For places where creating a text file I use the command:
sudo su -c 'cat > /etc/somefile << "EOF"
Write text here
And here


More information about the lfs-support mailing list