When logged in as user root
, making a
single mistake can damage or destroy a system. Therefore, the
packages in the next two chapters are built as an unprivileged user.
You could use your own user name, but to make it easier to set up a
clean working environment, we will create a new user called
lfs
as a member of a new group (also
named lfs
) and run commands as
lfs
during the installation process.
As root
, issue the following commands
to add the new user:
groupadd lfs useradd -s /bin/bash -g lfs -m -k /dev/null lfs
This is what the command line options mean:
-s
/bin/bash
This makes bash
the default shell for user lfs
.
-g
lfs
This option adds user lfs
to
group lfs
.
-m
This creates a home directory for lfs
.
-k
/dev/null
This parameter prevents possible copying of files from a
skeleton directory (the default is /etc/skel
) by changing the input location to
the special null device.
lfs
This is the name of the new user.
If you want to log in as lfs
or
switch to lfs
from a non-root
user (as opposed to switching to user
lfs
when logged in as root
, which does not require the lfs
user to have a password), you need to set a
password for lfs
. Issue the following
command as the root
user to set the
password:
passwd lfs
Grant lfs
full access to all the
directories under $LFS
by making
lfs
the owner:
chown -v lfs $LFS/{usr{,/*},lib,lib64,var,etc,bin,sbin,tools}
In some host systems, the following su command does not complete
properly and suspends the login for the lfs
user to the background. If the prompt
"lfs:~$" does not appear immediately, entering the fg command will fix the issue.
Next, start a shell running as user lfs
. This can be done by logging in as
lfs
on a virtual console, or with the
following substitute/switch user command:
su - lfs
The “-
” instructs su to start a login shell as
opposed to a non-login shell. The difference between these two types
of shells is described in detail in bash(1) and info bash.