creatingdirs.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-tools-creatingdirs">
  8. <?dbhtml filename="creatingdirs.html"?>
  9. <title>Creating Directories</title>
  10. <para>It is time to create the full structure in the LFS file system.</para>
  11. <para>Create some root-level directories that are not in the limited set
  12. required in the previous chapters by issuing the following command:</para>
  13. <note><para>Some of the directories below have already been created earlier
  14. with explicit instructions or when installing some packages. They are
  15. repeated below for completeness.</para></note>
  16. <screen><userinput>mkdir -pv /{boot,home,mnt,opt,srv}</userinput></screen>
  17. <para>Create the required set of subdirectories below the root-level by
  18. issuing the following commands:</para>
  19. <screen><userinput>mkdir -pv /etc/{opt,sysconfig}
  20. mkdir -pv /lib/firmware
  21. mkdir -pv /media/{floppy,cdrom}
  22. mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
  23. mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
  24. mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
  25. mkdir -pv /usr/{,local/}share/man/man{1..8}
  26. mkdir -pv /var/{cache,local,log,mail,opt,spool}
  27. mkdir -pv /var/lib/{color,misc,locate}
  28. ln -sfv /run /var/run
  29. ln -sfv /run/lock /var/lock
  30. install -dv -m 0750 /root
  31. install -dv -m 1777 /tmp /var/tmp</userinput></screen>
  32. <para>Directories are, by default, created with permission mode 755, but
  33. this is not desirable for all directories. In the commands above, two
  34. changes are made&mdash;one to the home directory of user <systemitem
  35. class="username">root</systemitem>, and another to the directories for
  36. temporary files.</para>
  37. <para>The first mode change ensures that not just anybody can enter
  38. the <filename class="directory">/root</filename> directory&mdash;the
  39. same as a normal user would do with his or her home directory. The
  40. second mode change makes sure that any user can write to the
  41. <filename class="directory">/tmp</filename> and <filename
  42. class="directory">/var/tmp</filename> directories, but cannot remove
  43. another user's files from them. The latter is prohibited by the so-called
  44. <quote>sticky bit,</quote> the highest bit (1) in the 1777 bit mask.</para>
  45. <sect2>
  46. <title>FHS Compliance Note</title>
  47. <para>The directory tree is based on the Filesystem Hierarchy Standard
  48. (FHS) (available at <ulink
  49. url="https://refspecs.linuxfoundation.org/fhs.shtml"/>). The FHS also specifies
  50. the optional existence of some directories such as <filename
  51. class="directory">/usr/local/games</filename> and <filename
  52. class="directory">/usr/share/games</filename>. We create only the
  53. directories that are needed. However, feel free to create these
  54. directories. </para>
  55. </sect2>
  56. </sect1>