creatingdirs.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <sect1 id="ch06-creatingdirs">
  2. <title>Creating directories</title>
  3. <?dbhtml filename="creatingdirs.html" dir="chapter06"?>
  4. <para>Let's now create some structure in our LFS file system. Let's create
  5. a directory tree. Issuing the following commands will create a more or less
  6. standard tree:</para>
  7. <para><screen><userinput>mkdir -p /{bin,boot,dev/{pts,shm},etc/opt,home,lib,mnt,proc}
  8. mkdir -p /{root,sbin,tmp,usr/local,var,opt}
  9. for dirname in /usr /usr/local
  10. &nbsp;&nbsp;&nbsp;&nbsp;do
  11. &nbsp;&nbsp;&nbsp;&nbsp;mkdir $dirname/{bin,etc,include,lib,sbin,share,src}
  12. &nbsp;&nbsp;&nbsp;&nbsp;ln -s share/{man,doc,info} $dirname
  13. &nbsp;&nbsp;&nbsp;&nbsp;mkdir $dirname/share/{dict,doc,info,locale,man}
  14. &nbsp;&nbsp;&nbsp;&nbsp;mkdir $dirname/share/{nls,misc,terminfo,zoneinfo}
  15. &nbsp;&nbsp;&nbsp;&nbsp;mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}
  16. done
  17. mkdir /usr/lib/locale
  18. mkdir /var/{lock,log,mail,run,spool}
  19. mkdir -p /var/{tmp,opt,cache,lib/misc,local}
  20. mkdir /opt/{bin,doc,include,info}
  21. mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}}
  22. ln -s ../var/tmp /usr</userinput></screen></para>
  23. <para>Directories are, by default, created with permission mode 755, but this
  24. isn't desirable for all directories. We will make two changes: one to the home
  25. directory of root, and another to the directories for temporary files.</para>
  26. <para><screen><userinput>chmod 0750 /root
  27. chmod 1777 /tmp /var/tmp</userinput></screen></para>
  28. <para>The first mode change ensures that not just anybody can enter the
  29. <filename class="directory">/root</filename> directory -- the same
  30. as a normal user would do with his or her home directory.
  31. The second mode change makes sure that any user can write to the
  32. <filename class="directory">/tmp</filename> and
  33. <filename class="directory">/var/tmp</filename> directories, but
  34. cannot remove other users' files from them. The latter is prohibited
  35. by the so-called "sticky bit" -- the highest bit in the 1777 bit mask.</para>
  36. <sect2>
  37. <title>FHS compliance note</title>
  38. <para>We have based our directory tree on the FHS standard (available at
  39. <ulink url="http://www.pathname.com/fhs/"/>). Besides the above created
  40. tree this standard stipulates the existence of
  41. <filename class="directory">/usr/local/games</filename> and
  42. <filename class="directory">/usr/share/games</filename>, but we don't
  43. much like these for a base system. However, feel free to make your system
  44. FHS-compliant. As to the structure of the
  45. <filename class="directory">/usr/local/share</filename> subdirectory, the FHS
  46. isn't precise, so we created here the directories that we think are needed.</para>
  47. </sect2>
  48. </sect1>