msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2020-08-08 19:28+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: zh_CN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Translate Toolkit 2.2.5\n" #. type: Content of: msgid "Creating Essential Files and Symlinks" msgstr "创建必要的文件和符号链接" #. type: Content of: <sect1><indexterm><primary> msgid "/etc/passwd" msgstr "/etc/passwd" #. type: Content of: <sect1><indexterm><primary> msgid "/etc/group" msgstr "/etc/group" #. type: Content of: <sect1><indexterm><primary> msgid "/var/run/utmp" msgstr "/var/run/utmp" #. type: Content of: <sect1><indexterm><primary> msgid "/var/log/btmp" msgstr "/var/log/btmp" #. type: Content of: <sect1><indexterm><primary> msgid "/var/log/lastlog" msgstr "/var/log/lastlog" #. type: Content of: <sect1><indexterm><primary> msgid "/var/log/wtmp" msgstr "/var/log/wtmp" #. type: Content of: <sect1><para> msgid "" "Historically, Linux maintains a list of the mounted file systems in the file " "<filename>/etc/mtab</filename>. Modern kernels maintain this list internally " "and exposes it to the user via the <filename class=\"directory\">/proc</" "filename> filesystem. To satisfy utilities that expect the presence of " "<filename>/etc/mtab</filename>, create the following symbolic link:" msgstr "" "历史上,Linux 在 <filename>/etc/mtab</filename> 维护已经挂载的文件系统的列" "表。现代内核在内部维护该列表,并通过 <filename class=\"directory\">/proc</" "filename> 文件系统将它展示给用户。为了满足那些需要 <filename>/etc/mtab</" "filename> 的工具,执行以下命令,创建符号链接:" #. type: Content of: <sect1><screen> #, no-wrap msgid "<userinput>ln -sv /proc/self/mounts /etc/mtab</userinput>" msgstr "<userinput>ln -sv /proc/self/mounts /etc/mtab</userinput>" #. type: Content of: <sect1><para> msgid "" "Create a basic <filename>/etc/hosts</filename> file to be referenced in some " "test suites, and in one of Perl's configuration files as well:" msgstr "" "创建一个基本的 <filename>/etc/hosts</filename> 文件,一些测试套件,以及 Perl " "的一个配置文件将会使用它:" #. type: Content of: <sect1><screen> #, no-wrap msgid "<userinput>echo \"127.0.0.1 localhost $(hostname)\" > /etc/hosts</userinput>" msgstr "<userinput>echo \"127.0.0.1 localhost $(hostname)\" > /etc/hosts</userinput>" #. type: Content of: <sect1><para> msgid "" "In order for user <systemitem class=\"username\">root</systemitem> to be " "able to login and for the name <quote>root</quote> to be recognized, there " "must be relevant entries in the <filename>/etc/passwd</filename> and " "<filename>/etc/group</filename> files." msgstr "" "为了使得 <systemitem class=\"username\">root</systemitem> 能正常登录,而且用" "户名 <quote>root</quote> 能被正常识别,必须在文件 <filename>/etc/passwd</" "filename> 和 <filename>/etc/groups</filename> 中写入相关的条目。" #. type: Content of: <sect1><para> msgid "" "Create the <filename>/etc/passwd</filename> file by running the following " "command:" msgstr "执行以下命令创建 <filename>/etc/passwd</filename> 文件:" #. type: Content of: <sect1><screen> #, no-wrap msgid "" "<userinput>cat > /etc/passwd << \"EOF\"\n" "<literal>root:x:0:0:root:/root:/bin/bash\n" "bin:x:1:1:bin:/dev/null:/bin/false\n" "daemon:x:6:6:Daemon User:/dev/null:/bin/false\n" "messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false\n" "nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>\n" "EOF</userinput>" msgstr "" "<userinput>cat > /etc/passwd << \"EOF\"\n" "<literal>root:x:0:0:root:/root:/bin/bash\n" "bin:x:1:1:bin:/dev/null:/bin/false\n" "daemon:x:6:6:Daemon User:/dev/null:/bin/false\n" "messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false\n" "nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>\n" "EOF</userinput>" #. type: Content of: <sect1><screen> #, no-wrap msgid "" "<userinput>cat > /etc/passwd << \"EOF\"\n" "<literal>root:x:0:0:root:/root:/bin/bash\n" "bin:x:1:1:bin:/dev/null:/bin/false\n" "daemon:x:6:6:Daemon User:/dev/null:/bin/false\n" "messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false\n" "systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false\n" "systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false\n" "systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false\n" "systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false\n" "systemd-network:x:76:76:systemd Network Management:/:/bin/false\n" "systemd-resolve:x:77:77:systemd Resolver:/:/bin/false\n" "systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false\n" "systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false\n" "nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>\n" "EOF</userinput>" msgstr "" "<userinput>cat > /etc/passwd << \"EOF\"\n" "<literal>root:x:0:0:root:/root:/bin/bash\n" "bin:x:1:1:bin:/dev/null:/bin/false\n" "daemon:x:6:6:Daemon User:/dev/null:/bin/false\n" "messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false\n" "systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false\n" "systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false\n" "systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false\n" "systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false\n" "systemd-network:x:76:76:systemd Network Management:/:/bin/false\n" "systemd-resolve:x:77:77:systemd Resolver:/:/bin/false\n" "systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false\n" "systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false\n" "nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>\n" "EOF</userinput>" #. type: Content of: <sect1><para> msgid "" "The actual password for <systemitem class=\"username\">root</systemitem> " "will be set later." msgstr "" "我们以后再设置 <systemitem class=\"username\">root</systemitem> 用户的实际密" "码。" #. type: Content of: <sect1><para> msgid "" "Create the <filename>/etc/group</filename> file by running the following " "command:" msgstr "执行以下命令,创建 <filename>/etc/group</filename> 文件:" #. type: Content of: <sect1><screen> #, no-wrap msgid "" "<userinput>cat > /etc/group << \"EOF\"\n" "<literal>root:x:0:\n" "bin:x:1:daemon\n" "sys:x:2:\n" "kmem:x:3:\n" "tape:x:4:\n" "tty:x:5:\n" "daemon:x:6:\n" "floppy:x:7:\n" "disk:x:8:\n" "lp:x:9:\n" "dialout:x:10:\n" "audio:x:11:\n" "video:x:12:\n" "utmp:x:13:\n" "usb:x:14:\n" "cdrom:x:15:\n" "adm:x:16:\n" "messagebus:x:18:\n" "input:x:24:\n" "mail:x:34:\n" "kvm:x:61:\n" "wheel:x:97:\n" "nogroup:x:99:\n" "users:x:999:</literal>\n" "EOF</userinput>" msgstr "" "<userinput>cat > /etc/group << \"EOF\"\n" "<literal>root:x:0:\n" "bin:x:1:daemon\n" "sys:x:2:\n" "kmem:x:3:\n" "tape:x:4:\n" "tty:x:5:\n" "daemon:x:6:\n" "floppy:x:7:\n" "disk:x:8:\n" "lp:x:9:\n" "dialout:x:10:\n" "audio:x:11:\n" "video:x:12:\n" "utmp:x:13:\n" "usb:x:14:\n" "cdrom:x:15:\n" "adm:x:16:\n" "messagebus:x:18:\n" "input:x:24:\n" "mail:x:34:\n" "kvm:x:61:\n" "wheel:x:97:\n" "nogroup:x:99:\n" "users:x:999:</literal>\n" "EOF</userinput>" #. type: Content of: <sect1><screen> #, no-wrap msgid "" "<userinput>cat > /etc/group << \"EOF\"\n" "<literal>root:x:0:\n" "bin:x:1:daemon\n" "sys:x:2:\n" "kmem:x:3:\n" "tape:x:4:\n" "tty:x:5:\n" "daemon:x:6:\n" "floppy:x:7:\n" "disk:x:8:\n" "lp:x:9:\n" "dialout:x:10:\n" "audio:x:11:\n" "video:x:12:\n" "utmp:x:13:\n" "usb:x:14:\n" "cdrom:x:15:\n" "adm:x:16:\n" "messagebus:x:18:\n" "systemd-journal:x:23:\n" "input:x:24:\n" "mail:x:34:\n" "kvm:x:61:\n" "systemd-bus-proxy:x:72:\n" "systemd-journal-gateway:x:73:\n" "systemd-journal-remote:x:74:\n" "systemd-journal-upload:x:75:\n" "systemd-network:x:76:\n" "systemd-resolve:x:77:\n" "systemd-timesync:x:78:\n" "systemd-coredump:x:79:\n" "wheel:x:97:\n" "nogroup:x:99:\n" "users:x:999:</literal>\n" "EOF</userinput>" msgstr "" "<userinput>cat > /etc/group << \"EOF\"\n" "<literal>root:x:0:\n" "bin:x:1:daemon\n" "sys:x:2:\n" "kmem:x:3:\n" "tape:x:4:\n" "tty:x:5:\n" "daemon:x:6:\n" "floppy:x:7:\n" "disk:x:8:\n" "lp:x:9:\n" "dialout:x:10:\n" "audio:x:11:\n" "video:x:12:\n" "utmp:x:13:\n" "usb:x:14:\n" "cdrom:x:15:\n" "adm:x:16:\n" "messagebus:x:18:\n" "systemd-journal:x:23:\n" "input:x:24:\n" "mail:x:34:\n" "kvm:x:61:\n" "systemd-bus-proxy:x:72:\n" "systemd-journal-gateway:x:73:\n" "systemd-journal-remote:x:74:\n" "systemd-journal-upload:x:75:\n" "systemd-network:x:76:\n" "systemd-resolve:x:77:\n" "systemd-timesync:x:78:\n" "systemd-coredump:x:79:\n" "wheel:x:97:\n" "nogroup:x:99:\n" "users:x:999:</literal>\n" "EOF</userinput>" #. type: Content of: <sect1><para> msgid "" "The created groups are not part of any standard—they are groups " "decided on in part by the requirements of the Udev configuration in Chapter " "9, and in part by common convention employed by a number of existing Linux " "distributions. In addition, some test suites rely on specific users or " "groups. The Linux Standard Base (LSB, available at <ulink url=\"http://" "refspecs.linuxfoundation.org/lsb.shtml\"/>) only recommends that, besides " "the group <systemitem class=\"groupname\">root</systemitem> with a Group ID " "(GID) of 0, a group <systemitem class=\"groupname\">bin</systemitem> with a " "GID of 1 be present. All other group names and GIDs can be chosen freely by " "the system administrator since well-written programs do not depend on GID " "numbers, but rather use the group's name." msgstr "" "这里创建的用户组并不属于任何标准 —— 它们一部分是为了满足第 9 章中 Udev 配置的" "需要,另一部分借鉴了一些 Linux 发行版的通用惯例。另外,某些测试套件需要特定的" "用户或组。Linux Standard Base (LSB,可以在 <ulink url=\"http://www.linuxbase." "org\"/> 查看) 标准只推荐以组 ID 0 创建用户组 <systemitem class=\"groupname" "\">root</systemitem>,以及以组 ID 1 创建用户组 <systemitem class=\"groupname" "\">bin</systemitem>,其他组名和组 ID 由系统管理员自由分配,因为好的程序不会依" "赖组 ID 数字,而是使用组名。" #. type: Content of: <sect1><para> msgid "" "Some tests in <xref linkend=\"chapter-building-system\"/> need a regular " "user. We add this user here and delete this account at the end of that " "chapter." msgstr "" "<xref linkend=\"chapter-building-system\"/>中的一些测试需要使用一个普通用户。" "我们这里创建一个用户,在那一章的末尾再删除该用户。" #. type: Content of: <sect1><screen> #, no-wrap msgid "" "<userinput>echo \"tester:x:$(ls -n $(tty) | cut -d\" \" -f3):101::/home/tester:/bin/bash\" >> /etc/passwd\n" "echo \"tester:x:101:\" >> /etc/group\n" "install -o tester -d /home/tester</userinput>" msgstr "" "<userinput>echo \"tester:x:$(ls -n $(tty) | cut -d\" \" -f3):101::/home/tester:/bin/bash\" >> /etc/passwd\n" "echo \"tester:x:101:\" >> /etc/group\n" "install -o tester -d /home/tester</userinput>" #. type: Content of: <sect1><para> msgid "" "To remove the <quote>I have no name!</quote> prompt, start a new shell. " "Since the <filename>/etc/passwd</filename> and <filename>/etc/group</" "filename> files have been created, user name and group name resolution will " "now work:" msgstr "" "为了移除 <quote>I have no name!</quote> 提示符,需要打开一个新 shell。由于已" "经创建了文件 <filename>/etc/passwd</filename> 和 <filename>/etc/group</" "filename>,用户名和组名现在就可以正常解析了:" #. type: Content of: <sect1><screen> #, no-wrap msgid "<userinput>exec /bin/bash --login +h</userinput>" msgstr "<userinput>exec /bin/bash --login +h</userinput>" #. type: Content of: <sect1><para> msgid "" "Note the use of the <parameter>+h</parameter> directive. This tells " "<command>bash</command> not to use its internal path hashing. Without this " "directive, <command>bash</command> would remember the paths to binaries it " "has executed. To ensure the use of the newly compiled binaries as soon as " "they are installed, the <parameter>+h</parameter> directive will be used for " "the duration of this and the next chapter." msgstr "" "注意这里使用了 <parameter>+h</parameter> 参数。它告诉 <command>bash</" "command> 不要使用内部的路径散列机制。如果没有指定该参数,<command>bash</" "command> 会记忆它执行过程序的路径。为了在安装新编译好的程序后马上使用它们,在" "本章和下一章中总是使用 <parameter>+h</parameter>。" #. type: Content of: <sect1><para> msgid "" "The <command>login</command>, <command>agetty</command>, and <command>init</" "command> programs (and others) use a number of log files to record " "information such as who was logged into the system and when. However, these " "programs will not write to the log files if they do not already exist. " "Initialize the log files and give them proper permissions:" msgstr "" "<command>login</command>、<command>agetty</command> 和 <command>init</" "command> 等程序使用一些日志文件,以记录登录系统的用户和登录时间等信息。然而," "这些程序不会创建不存在的日志文件。初始化日志文件,并为它们设置合适的访问权" "限:" #. type: Content of: <sect1><screen> #, no-wrap msgid "" "<userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}\n" "chgrp -v utmp /var/log/lastlog\n" "chmod -v 664 /var/log/lastlog\n" "chmod -v 600 /var/log/btmp</userinput>" msgstr "" "<userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}\n" "chgrp -v utmp /var/log/lastlog\n" "chmod -v 664 /var/log/lastlog\n" "chmod -v 600 /var/log/btmp</userinput>" #. type: Content of: <sect1><para> msgid "" "The <filename>/var/log/wtmp</filename> file records all logins and logouts. " "The <filename>/var/log/lastlog</filename> file records when each user last " "logged in. The <filename>/var/log/faillog</filename> file records failed " "login attempts. The <filename>/var/log/btmp</filename> file records the bad " "login attempts." msgstr "" "文件 <filename>/var/log/wtmp</filename> 记录所有的登录和登出,文件 " "<filename>/var/log/lastlog</filename> 记录每个用户最后登录的时间,文件 " "<filename>/var/log/faillog</filename> 记录所有失败的登录尝试,文件 " "<filename>/var/log/btmp</filename> 记录所有错误的登录尝试。" #. type: Content of: <sect1><note><para> msgid "" "The <filename>/run/utmp</filename> file records the users that are currently " "logged in. This file is created dynamically in the boot scripts." msgstr "" "文件 <filename>/run/utmp</filename> 记录当前登录的用户,它由引导脚本动态创" "建。"