4.4. Adding the CLFS User

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

groupadd clfs
useradd -s /bin/bash -g clfs -d /home/clfs clfs
mkdir -pv /home/clfs
chown -v clfs:clfs /home/clfs

The meaning of the command line options:

-s /bin/bash

This makes bash the default shell for user clfs.



The build instructions assume that the bash shell is in use.

-g clfs

This option adds the new user to the clfs group.

-d /home/clfs

This option sets the user's home directory, but does not create it. We could have used -m to tell useradd to create the directory as well, but this would also copy the contents of the host system's /etc/skel directory into the new user's home. We would prefer to have a clean user environment, so we just create an empty directory after adding the user.


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

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

passwd clfs

As root, grant clfs full access to ${CLFS}/cross-tools and ${CLFS}/tools by making clfs the directorys' owner:

chown -v clfs ${CLFS}/tools
chown -v clfs ${CLFS}/cross-tools

If a separate working directory was created as suggested, run the following command as root to give user clfs ownership of this directory as well:

chown -v clfs ${CLFS}/sources

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

su - clfs

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.



Until specified otherwise, all commands from this point on should be done as the clfs user.