creatingdirs.xml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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-system-creatingdirs">
  8. <?dbhtml filename="creatingdirs.html"?>
  9. <title>Creating Directories</title>
  10. <para>It is time to create some structure in the LFS file system. Create a
  11. standard directory tree by issuing the following commands:</para>
  12. <screen><userinput>mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
  13. mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
  14. install -dv -m 0750 /root
  15. install -dv -m 1777 /tmp /var/tmp
  16. mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
  17. mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
  18. mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
  19. mkdir -v /usr/libexec
  20. mkdir -pv /usr/{,local/}share/man/man{1..8}
  21. case $(uname -m) in
  22. x86_64) ln -sv lib /lib64
  23. ln -sv lib /usr/lib64
  24. ln -sv lib /usr/local/lib64 ;;
  25. esac
  26. mkdir -v /var/{log,mail,spool}
  27. ln -sv /run /var/run
  28. ln -sv /run/lock /var/lock
  29. mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local}</userinput></screen>
  30. <para>Directories are, by default, created with permission mode 755, but
  31. this is not desirable for all directories. In the commands above, two
  32. changes are made&mdash;one to the home directory of user <systemitem
  33. class="username">root</systemitem>, and another to the directories for
  34. temporary files.</para>
  35. <para>The first mode change ensures that not just anybody can enter
  36. the <filename class="directory">/root</filename> directory&mdash;the
  37. same as a normal user would do with his or her home directory. The
  38. second mode change makes sure that any user can write to the
  39. <filename class="directory">/tmp</filename> and <filename
  40. class="directory">/var/tmp</filename> directories, but cannot remove
  41. another user's files from them. The latter is prohibited by the so-called
  42. <quote>sticky bit,</quote> the highest bit (1) in the 1777 bit mask.</para>
  43. <sect2>
  44. <title>FHS Compliance Note</title>
  45. <para>The directory tree is based on the Filesystem Hierarchy Standard (FHS)
  46. (available at <ulink url="https://wiki.linuxfoundation.org/en/FHS"/>).
  47. The FHS also stipulates the existence of <filename
  48. class="directory">/usr/local/games</filename> and <filename
  49. class="directory">/usr/share/games</filename>. The FHS is not precise as to
  50. the structure of the <filename class="directory">/usr/local/share</filename>
  51. subdirectory, so we create only the directories that are needed. However,
  52. feel free to create these directories if you prefer to conform more strictly
  53. to the FHS.</para>
  54. </sect2>
  55. </sect1>