Creating directories

Let's create the directory tree on the LFS partition based on the FHS standard, which can be found at http://www.pathname.com/fhs/. Issuing the following commands will create a default directory layout:



cd $LFS
mkdir -p bin boot dev/pts etc home lib mnt proc root sbin tmp var
for dirname in $LFS/usr $LFS/usr/local
锟斤拷锟絛o
锟斤拷锟絤kdir $dirname
锟斤拷锟絚d $dirname
锟斤拷锟絤kdir bin etc include lib sbin share src tmp var
锟斤拷锟絣n -s share/man man
锟斤拷锟絣n -s share/doc doc
锟斤拷锟絣n -s share/info info
锟斤拷锟絚d $dirname/share
锟斤拷锟絤kdir dict doc info locale man nls misc terminfo zoneinfo
锟斤拷锟絚d $dirname/share/man
锟斤拷锟絤kdir man1 man2 man3 man4 man5 man6 man7 man8
done
cd $LFS/var
mkdir lock log mail run spool tmp

Normally, directories are created with permission mode 755, which isn't desired for all directories. The first change is a mode 0750 for the $LFS/root directory. This is to make sure that not just everybody can enter the /root directory (the same a user would do with /home/username directories). The second change is a mode 1777 for the tmp directories. This way, any user can write data to the /tmp directory but cannot remove another user's files (the latter is caused by the so-called "sticky bit" - bit 1 of the 1777 bit mask).



cd $LFS &&
chmod 0750 root &&
chmod 1777 tmp usr/tmp usr/local/tmp var/tmp

Now that the directories are created, copy the source files that were downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you will need to create the desired directory yourself).