⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lsg17.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 3 页
字号:


<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->


























<LINK REL="ToC" HREF="index.htm">







<LINK REL="Index" HREF="htindex.htm">







<LINK REL="Next" HREF="lsg18.htm">



















<A NAME="I0"></A>







<H2>Linux System Administrator's Survival Guide lsg17.htm</H2>







<P ALIGN=LEFT>







































<HR ALIGN=CENTER>







<P>







<UL>







<UL>







<UL>







<LI>







<A HREF="#E68E95" >Setting a System Name</A>







<UL>







<LI>







<A HREF="#E69E123" >Creating Network System Names</A>







<LI>







<A HREF="#E69E124" >Storing the Hostname</A></UL>







<LI>







<A HREF="#E68E96" >Using File and Directory Permissions</A>







<UL>







<LI>







<A HREF="#E69E125" >Understanding File Types</A>







<LI>







<A HREF="#E69E126" >Understanding Access Permissions</A>







<LI>







<A HREF="#E69E127" >Using Default Permissions</A>







<LI>







<A HREF="#E69E128" >Changing Permissions</A>







<LI>







<A HREF="#E69E129" >Changing the Owner and Group</A></UL>







<LI>







<A HREF="#E68E97" >Summary</A></UL></UL></UL>







<HR ALIGN=CENTER>







<A NAME="E66E20"></A>







<H1 ALIGN=CENTER>







<CENTER>







<FONT SIZE=6 COLOR="#FF0000"><B>Chapter 17</B></FONT></CENTER></H1>







<BR>







<A NAME="E67E23"></A>







<H2 ALIGN=CENTER>







<CENTER>







<FONT SIZE=6 COLOR="#FF0000"><B>System Names and Access Permissions</B></FONT></CENTER></H2>







<BR>







<P>Instead of referring to your Linux system as &quot;it&quot; or &quot;that thing,&quot; you can give it a name that it recognizes to some extent. This name is especially important when you deal with e-mail or networks where others must have some method of identifying your machine from all the others on the network. This chapter starts by looking at how to give your machine a name and what rules you must follow to ensure other machines can work with your newly named machine.







<BR>







<P>The rest of this chapter looks at access permissions, a confusing subject for many system administrators. The permission block is often completely misunderstood, and the permissions attached to files and directories are often set incorrectly, preventing access to users who need it or worse, allowing wide-open access to sensitive information. After explaining how permissions work, this chapter explains how to change and set permissions and ownerships.







<BR>







<BR>







<A NAME="E68E95"></A>







<H3 ALIGN=CENTER>







<CENTER>







<FONT SIZE=5 COLOR="#FF0000"><B>Setting a System Name</B></FONT></CENTER></H3>







<BR>







<P>Because Linux is designed with networking in mind, it enables you to identify each machine with a unique name. You can name your system anything you want. In some cases, the setup or installation script that installed Linux for you may have asked you for a system name. You can keep the name you entered then or enter a new one.







<BR>







<P>The name that identifies your Linux system is called a hostname. This name, as mentioned, facilitates networking and associated services like e-mail. It also lets you give your system a bit of a personality. You can display the current Linux system hostname with the hostname command:







<BR>







<PRE>







<FONT COLOR="#000080">$ hostname







artemis</FONT></PRE>







<P>This code shows that the system's hostname is artemis. If you have no system hostname defined, Linux defaults to either no name or a system default name. The name information is read from the Linux system startup files.







<BR>







<P>If your system isn't networked, you can call your system anything you like, but remember that you have to live with it! To set your system name, run the hostname command with the -S option as shown in this example:







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">hostname -S superduck</FONT></PRE>







<P>This sample code sets your system hostname to superduck. This name is tagged onto all your e-mail and some system utilities when generating output. Some versions of Linux limit the hostname to a number of characters (usually 14 characters), but try any name you want. If Linux doesn't allow it, you should get an error message or see a truncated version of the name.







<BR>







<BR>







<A NAME="E69E123"></A>







<H4 ALIGN=CENTER>







<CENTER>







<FONT SIZE=4 COLOR="#FF0000"><B>Creating Network System Names</B></FONT></CENTER></H4>







<BR>







<P>If you are running on a network, the hostname is important. On a network, each machine must have a unique name, or the network can't identify which of the duplicate names the network information is for. If you are creating a local area network that is not connected to the Internet or has no formal network name, you can pick any network name you want. Your machine name and network name combined form the full machine name. For example, the command







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">hostname -S superduck.quackers</FONT></PRE>







<P>is composed of a machine name of superduck and a network name of quackers. As long as all the other machines on the network have the same network name, your machines can communicate properly. Your machine is uniquely identified by the combination of machine and network name.







<BR>







<P>If your system can access the Internet, your network probably has been assigned a network name by the Internet Network Information Center (NIC), which assigns network names, called domains, in accordance with strict naming conventions. Each domain has a unique name portion and an extension that identifies the type of organization to which the network belongs. For example, the company Quacks-R-Us may have a domain name quacks.com. The seven different extensions in use are as follows:







<BR>















<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.arpa







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







A governmental network identifier</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.com







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







Commercial company</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.edu







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







Educational institution</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.gov







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







Governmental body</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.mil







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







Military</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.net







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







An Internet-administered (usually) network</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







.org







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







Anything that isn't in one of the other categories</FONT>







</TABLE><P>These identifiers are usually used only for networks based in the U.S. Other countries have unique identifiers based on the country's name. For example, if Quacks-R-Us were based in the United Kingdom, the domain name could be quacks.uk. Each country has a two-letter designation that identifies it to the Internet. (Some companies have a U.S.-style extension even though they are outside U.S. borders. These companies usually have been registered by a U.S. company or have been on the Internet a long time.)







<BR>







<P>The combination of domain name and extension, as assigned by the NIC, is unique to each network. When combined with a hostname on the network, the result is a unique name for your machine. For example, if your local network has the domain name of quack.com and you want to name your machine superduck, you set the name of your machine with this command, which combines the machine and network names:







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">hostname -S superduck.quack.com</FONT></PRE>







<P>The chapters in Part IV, &quot;Networking,&quot; discuss machine names and network names in more detail. You may also want to check with a good TCP/IP book for more information. The author's <I>Teach Yourself TCP/IP in 14 Days</I> from Sams is a good place to start.







<BR>







<BR>







<A NAME="E69E124"></A>







<H4 ALIGN=CENTER>







<CENTER>







<FONT SIZE=4 COLOR="#FF0000"><B>Storing the Hostname</B></FONT></CENTER></H4>







<BR>







<P>Linux stores the hostname in the file /etc/hosts. If you have just installed Linux and haven't configured a machine name, the /etc/hosts file contains a bunch of comment lines and one line of code:







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">127.0.0.1 localhost</FONT></PRE>







<BLOCKQUOTE>







<BLOCKQUOTE>







<HR ALIGN=CENTER>







<BR>







<NOTE>Some Linux versions store the hostname in the /etc/rc or /etc/rc.local files or in the directory /etc/rc.d, although this convention is absent from most versions of Linux.</NOTE>







<BR>







<HR ALIGN=CENTER>







</BLOCKQUOTE></BLOCKQUOTE>







<P>The /etc/hosts file consists of two columns, one for the IP address and the second for machine names. The four numbers (written in a format called dotted-quad as there are four groups of numbers with periods between them) are the IP address. IP stands for Internet Protocol and is an essential component of the TCP/IP network protocols used on the Internet and most local area networks involving UNIX. The IP address for machines connected to the Internet is assigned by the Network Information Center, just as the domain name is. (The IP address and domain name also are mapped to each other so the network can use numbers instead of names, a much more efficient system.) If you are not connected to the Internet, your IP address can be anything as long as each set of numbers is in the range 0 to 255.







<BR>







<P>The IP address is composed of the network identifier and the machine identifier. The four parts of the IP address are split over these two identifiers in special ways. If you are connecting to an existing TCP/IP network, your network administrator will give you the IP address you should use. The IP address 127.0.0.1 is a special address known as the loopback address. This address lets TCP/IP on your machine form a connection to itself. Every machine has a loopback driver, which is identified by the entry 127.0.0.1 in the /etc/hosts file and the name localhost.







<BR>







<P>If you have identified your machine by a hostname already, that name is in the /etc/hosts file. For example, the stand-alone machine called superduck from earlier in this section is given on the same line as the localhost entry:







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">127.0.0.1 superduck localhost</FONT></PRE>







<P>This line tells the system that the localhost is called superduck and to use that name as the system identifier.







<BR>







<P>This naming process gets a little more complicated when you are on a network, as each machine on the network has an IP address that is unique. If your network is not connected to the Internet, you can make up any IP address for your network. If you are on the Internet, your network IP address is assigned, and the network administrator can give you your machine's IP address or you can choose an unused address.







<BR>







<P>Suppose you are connecting to the Internet and your IP address is 47.123.23.37 and your domain name is quacks.com. Your /etc/hosts file looks like the following:







<BR>







<PRE>







<FONT COLOR="#000080">127.0.0.1 localhost







47.123.23.37 superduck.quacks.com</FONT></PRE>







<P>The name superduck may appear on the localhost line as well, although it doesn't have to. The /etc/hosts file may have other lines when you are connected to a large network that you move around in frequently. At least these two lines should appear when you are connected to a network, though.







<BR>







<BR>







<A NAME="E68E96"></A>







<H3 ALIGN=CENTER>







<CENTER>







<FONT SIZE=5 COLOR="#FF0000"><B>Using File and Directory Permissions</B></FONT></CENTER></H3>







<BR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -