4.3. Adding the HLFS User

When logged in as user root, making a single mistake can damage or destroy a system. Therefore, we recommend building the packages in this chapter as an unprivileged user. You could use your own user name, but to make it easier to set up a clean working environment, create a new user called hlfs as a member of a new group (also named hlfs) and use this user during the installation process. As root, issue the following commands to add the new user:

groupadd hlfs
useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs

The meaning of the command line options:

-s /bin/bash

This makes bash the default shell for user hlfs.

-g hlfs

This option adds user hlfs to group hlfs.

-m

This creates a home directory for hlfs.

-k /dev/null

This parameter prevents possible copying of files from a skeleton directory (default is /etc/skel) by changing the input location to the special null device.

lfs

This is the actual name for the created group and user.

To log in as hlfs (as opposed to switching to user hlfs when logged in as root, which does not require the hlfs user to have a password), give hlfs a password:

passwd hlfs

Grant hlfs full access to $HLFS/tools by making hlfs the directory owner:

chown -v hlfs $HLFS/tools

If a separate working directory was created as suggested, give user hlfs ownership of this directory:

chown -v hlfs $HLFS/sources

Next, login as user hlfs. This can be done via a virtual console, through a display manager, or with the following substitute user command:

su - hlfs

The “-” instructs su to start a login shell as opposed to a non-login shell. The difference between these two types of shells can be found in detail in bash(1) and info bash.