aboutsummaryrefslogtreecommitdiffstats
path: root/chapter03/creatingdirs.xml
blob: 463688456c4d82de651b82c6c0dc73fcb933bcf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<sect1 id="ch04-creatingdirs">
<title>Creating directories</title>

<para>
Let's create the directory tree on the LFS partition based on the FHS
standard, which can be found at <ulink
url="http://www.pathname.com/fhs/">http://www.pathname.com/fhs/</ulink>.
Issuing the following commands will create a default directory layout:
</para>
 
<blockquote><literallayout>

	<userinput>cd $LFS</userinput>
	<userinput>mkdir -p bin boot dev/pts etc home lib mnt proc root sbin 
		tmp var</userinput>
	<userinput>for dirname in $LFS/usr $LFS/usr/local</userinput>
	<userinput><literal>&nbsp;&nbsp;&nbsp;do</literal></userinput>
	<userinput>&nbsp;&nbsp;&nbsp;mkdir $dirname</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;cd $dirname</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;mkdir bin etc include lib sbin share 
		src tmp var</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;ln -s share/man man</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;ln -s share/doc doc</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;ln -s share/info info</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;cd $dirname/share</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;mkdir dict doc info locale man nls misc 
		terminfo zoneinfo</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;cd $dirname/share/man</userinput>
	<userinput>&nbsp;&nbsp;&nbsp;mkdir man1 man2 man3 man4 man5 man6 man7 
		man8</userinput>
	<userinput>done</userinput>
	<userinput>cd $LFS/var</userinput>
	<userinput>mkdir lock log mail run spool tmp</userinput>

</literallayout></blockquote>

<para>
Normally, directories are created with permission mode 755, which isn't
desired for all directories. The first change is a mode 0750 for the 
$LFS/root directory. This is to make sure that not just everybody can 
enter the /root directory (the same a user would do with /home/username 
directories). The second change is a mode 1777 for the tmp 
directories. This way, any user can write data to the /tmp directory when
needed. The sticky bit (the first bit in the 1777 mask) makes sure 
users can't delete other users files which they normally can do, 
because the directory is set in such a way that everybody (owner, group, 
world) can write to that directory (the 777 in the bit mask)
</para>

<blockquote><literallayout>

	<userinput>cd $LFS &amp;&amp;</userinput>
	<userinput>chmod 0750 root &amp;&amp;</userinput>
	<userinput>chmod 1777 tmp usr/tmp usr/local/tmp var/tmp</userinput>

</literallayout></blockquote>

<para>
Now that the directories are created, copy the source files that were
downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you
will need to create the desired directory yourself).
</para>

</sect1>