creatingdirs.xml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <sect1 id="ch04-creatingdirs">
  2. <title>Creating directories</title>
  3. <para>Let's create the directory tree on the LFS partition based on the FHS
  4. standard, which can be found at <ulink
  5. url="http://www.pathname.com/fhs/">http://www.pathname.com/fhs/</ulink>.
  6. Issuing the following commands will create a default directory layout:</para>
  7. <para><screen><userinput>cd $LFS</userinput>
  8. <userinput>mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt</userinput>
  9. <userinput>for dirname in $LFS/usr $LFS/usr/local</userinput>
  10. <userinput><literal>&nbsp;&nbsp;&nbsp;do</literal></userinput>
  11. <userinput>&nbsp;&nbsp;&nbsp;mkdir $dirname</userinput>
  12. <userinput>&nbsp;&nbsp;&nbsp;cd $dirname</userinput>
  13. <userinput>&nbsp;&nbsp;&nbsp;mkdir bin etc include lib sbin share src var</userinput>
  14. <userinput>&nbsp;&nbsp;&nbsp;ln -s share/man man</userinput>
  15. <userinput>&nbsp;&nbsp;&nbsp;ln -s share/doc doc</userinput>
  16. <userinput>&nbsp;&nbsp;&nbsp;ln -s share/info info</userinput>
  17. <userinput>&nbsp;&nbsp;&nbsp;cd $dirname/share</userinput>
  18. <userinput>&nbsp;&nbsp;&nbsp;mkdir dict doc info locale man nls misc terminfo zoneinfo</userinput>
  19. <userinput>&nbsp;&nbsp;&nbsp;cd $dirname/share/man</userinput>
  20. <userinput>&nbsp;&nbsp;&nbsp;mkdir man{1,2,3,4,5,6,7,8}</userinput>
  21. <userinput>done</userinput>
  22. <userinput>cd $LFS/var</userinput>
  23. <userinput>mkdir -p lock log mail run spool tmp opt cache lib/misc local</userinput>
  24. <userinput>cd $LFS/opt</userinput>
  25. <userinput>mkdir bin doc include info lib man</userinput>
  26. <userinput>cd $LFS/usr</userinput>
  27. <userinput>ln -s ../var/tmp tmp</userinput></screen></para>
  28. <para>Normally, directories are created with permission mode 755, which isn't
  29. desired for all directories. The first change is a mode 0750 for the
  30. $LFS/root directory. This is to make sure that not just everybody can
  31. enter the /root directory (the same a user would do with /home/username
  32. directories). The second change is a mode 1777 for the tmp
  33. directories. This way, any user can write data to the /tmp or /var/tmp
  34. directory but cannot remove another user's files (the latter is caused
  35. by the so-called "sticky bit" - bit 1 of the 1777 bit mask).</para>
  36. <para><screen><userinput>cd $LFS &amp;&amp;</userinput>
  37. <userinput>chmod 0750 root &amp;&amp;</userinput>
  38. <userinput>chmod 1777 tmp var/tmp</userinput></screen></para>
  39. <para>Now that the directories are created, copy the source files that were
  40. downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you
  41. will need to create the desired directory yourself).</para>
  42. <sect2>
  43. <title>FHS compliance notes</title>
  44. <para>The FHS stipulates that the /usr/local directory should contain the
  45. bin, games,include, lib, man, sbin, and share subdirectories. You can
  46. alter your /usr/local directory yourself if you want your system
  47. to be FHS-compliant.</para>
  48. <para>Also, the standard says that there should exist a /usr/share/games
  49. directory, which we don't much like for a base system. But feel free to
  50. make your system FHS-compliant if you wish. The FHS isn't precise as
  51. to the structure of the /usr/local/share subdirectories, so we took the
  52. liberty of creating the directories that we felt needed.</para>
  53. </sect2>
  54. </sect1>