users and scripts

Tushar T tush at
Thu Oct 24 13:41:02 PDT 2002

Eric Miller wrote:

>I am doing my 4.0 install partially scripted.  I am wondering, if an install
>script is run as user lfs or root or whatever, does the script run as that
>user, or as a system uid?
>Just wanna make sure that running scripts during install won't create
>ownership problems because things were built as a function of a script, even
>though the script was executed by the correct user (root or lfs as required
>by the book).
>This may sound like a silly question, but here is the root of it:  I have
>all of chapter 5 completely scripted, and it runs flawlessly.  The script
>declares LFS=/mnt/lfs and some other env variables that are useful (e.g.
>src=/$LFS/static/src/), and the script itself uses these to install all of
>Chapter 5 without error.  However, when the script is finished, and is
>kicked back out to the prompt, if I echo $LFS or $src, I get nothing?  Yes,
>I have two seperate scripts, one for pre su - lfs and one for post su -lfs.
>Both scripts declare both values at the beginning and run perfectly.
>Is there a difference between 'LFS=/mnt/lfs' and 'export LFS=/mnt/lfs'?  I
>have tried it both ways and still get nothing when I echo either $value
>after the script has finished successfully.
Based on your questions, I would recommend that you check out the LDP at 

Now as for the answers:

   1. The script runs as the user that calls it (unless of course the
      SID bit is set, but that is a different matter).
   2. When you run your ch5 script, the export LFS in the script exports
      the variable LFS to that process and the subprocesses it creates.
      There is no way to export it back to the parent process. Hence
      after the script exists, the parent process (your shell) won't
      know about the variable that was exported in the child.
   3. export LFS will make the value of the variable available to all
      the subprocesses, if you don't use export, only the current
      process will be aware of the variable.

If you have any more questions after referring to the documentation, 
please post to lfs-chat.

Tushar Teredesai
LFS ID: 1377

Unsubscribe: send email to listar at
and put 'unsubscribe lfs-support' in the subject header of the message

More information about the lfs-support mailing list