creatingdirs.html
来自「lfs3.1 从源代码构建linux。html版本。」· HTML 代码 · 共 392 行
HTML
392 行
<HTML><HEAD><TITLE>Creating directories</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.63"><LINKREL="HOME"TITLE="Linux From Scratch"HREF="../index.html"><LINKREL="UP"TITLE="Preparing a new partition"HREF="../chapter04/chapter04.html"><LINKREL="PREVIOUS"TITLE="Mounting the new partition"HREF="../chapter04/mounting.html"><LINKREL="NEXT"TITLE="Preparing the LFS system"HREF="../chapter05/chapter05.html"></HEAD><BODYCLASS="sect1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Linux From Scratch: Version 3.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="../chapter04/mounting.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 4. Preparing a new partition</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="../chapter05/chapter05.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="sect1"><H1CLASS="sect1"><ANAME="ch04-creatingdirs">4.5. Creating directories</A></H1><P>Before we start creating directories, we need to check the basesystem's umask setting. To do this, we run<TTCLASS="userinput"><B>umask</B></TT>. The result should be 022. If it isn't,then run the following command to ensure that the directories will becreated with the correct permissions:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>umask 022</B></TT></PRE></FONT></TD></TR></TABLE></P><P>We would advise you to make sure that the umask is set to 022throughout your LFS installation.</P><P>Let's now create the directory tree on the LFS partition based on the FHSstandard, which can be found at <AHREF="http://www.pathname.com/fhs/"TARGET="_top">http://www.pathname.com/fhs/</A>.Issuing the following commands will create a default directory layout:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>cd $LFS &&</B></TT><TTCLASS="userinput"><B>mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt &&</B></TT><TTCLASS="userinput"><B>for dirname in $LFS/usr $LFS/usr/local</B></TT><TTCLASS="userinput"><B><TTCLASS="literal">牋燿o</TT></B></TT><TTCLASS="userinput"><B>牋爉kdir $dirname</B></TT><TTCLASS="userinput"><B>牋燾d $dirname</B></TT><TTCLASS="userinput"><B>牋爉kdir bin etc include lib sbin share src var</B></TT><TTCLASS="userinput"><B>牋爈n -s share/man man</B></TT><TTCLASS="userinput"><B>牋爈n -s share/doc doc</B></TT><TTCLASS="userinput"><B>牋爈n -s share/info info</B></TT><TTCLASS="userinput"><B>牋燾d $dirname/share</B></TT><TTCLASS="userinput"><B>牋爉kdir dict doc info locale man nls misc terminfo zoneinfo</B></TT><TTCLASS="userinput"><B>牋燾d $dirname/share/man</B></TT><TTCLASS="userinput"><B>牋爉kdir man{1,2,3,4,5,6,7,8}</B></TT><TTCLASS="userinput"><B>done</B></TT><TTCLASS="userinput"><B>cd $LFS/var &&</B></TT><TTCLASS="userinput"><B>mkdir -p lock log mail run spool tmp opt cache lib/misc local &&</B></TT><TTCLASS="userinput"><B>cd $LFS/opt &&</B></TT><TTCLASS="userinput"><B>mkdir bin doc include info lib man &&</B></TT><TTCLASS="userinput"><B>cd $LFS/usr &&</B></TT><TTCLASS="userinput"><B>ln -s ../var/tmp tmp</B></TT></PRE></FONT></TD></TR></TABLE></P><P>Normally, directories are created with permission mode 755, which isn'tdesired 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 or /var/tmp directory but cannot remove another user's files (the latter is caused by the so-called "sticky bit" - bit 1 of the 1777 bit mask).</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>cd $LFS &&</B></TT><TTCLASS="userinput"><B>chmod 0750 root &&</B></TT><TTCLASS="userinput"><B>chmod 1777 tmp var/tmp</B></TT></PRE></FONT></TD></TR></TABLE></P><P>Now that the directories are created, copy the source files that weredownloaded in chapter 3 to some subdirectory under $LFS/usr/src (youwill need to create the desired directory yourself).</P><DIVCLASS="sect2"><H2CLASS="sect2"><ANAME="AEN774">4.5.1. FHS compliance notes</A></H2><P>The FHS stipulates that the /usr/local directory should contain the bin, games,include, lib, man, sbin, and share subdirectories. You can alter your /usr/local directory yourself if you want your system to be FHS-compliant.</P><P>Also, the standard says that there should exist a /usr/share/games directory, which we don't much like for a base system. But feel free to make your system FHS-compliant if you wish. The FHS isn't precise as to the structure of the /usr/local/share subdirectories, so we took the liberty of creating the directories that we felt needed.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="../chapter04/mounting.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="../index.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="../chapter05/chapter05.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Mounting the new partition</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="../chapter04/chapter04.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Preparing the LFS system</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?