creatingdirs.xml 3.2 KB

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