creatingdirs.xml 2.7 KB

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