source: postlfs/config/skel.xml@ b3d9df0

11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since b3d9df0 was b3d9df0, checked in by Xi Ruoyao <xry111@…>, 19 months ago

useradd: add instructions for creating new user with same UID/GID on another system

  • Property mode set to 100644
File size: 6.8 KB
RevLine 
[f8d632a]1<?xml version="1.0" encoding="ISO-8859-1"?>
[6732c094]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[f8d632a]4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6]>
7
[0290a023]8<sect1 id="postlfs-config-skel" xreflabel="Configuring for Adding Users">
[991aa6f]9 <?dbhtml filename="skel.html"?>
10
11 <sect1info>
12 <date>$Date$</date>
13 </sect1info>
14
15 <title>Configuring for Adding Users</title>
16
17 <indexterm zone="postlfs-config-skel">
18 <primary sortas="e-etc-skel">/etc/skel/*</primary>
19 </indexterm>
20
21 <indexterm zone="postlfs-config-skel">
22 <primary sortas="e-etc-default-useradd">/etc/default/useradd</primary>
23 </indexterm>
24
[81a73ed8]25 <para>
26 Together, the <command>/usr/sbin/useradd</command> command and <filename
27 class="directory">/etc/skel</filename> directory (both are easy to
28 set up and use) provide a way to assure new users are added to your LFS
29 system with the same beginning settings for things such as the
30 <envar>PATH</envar>, keyboard processing and other environmental variables.
31 Using these two facilities makes it easier to assure this initial state for
32 each new user added to the system.
33 </para>
34
35 <para>
36 The <filename class="directory">/etc/skel</filename> directory holds
37 copies of various initialization and other files that may be copied to the
38 new user's home directory when the <command>/usr/sbin/useradd</command>
39 program adds the new user.
40 </para>
[991aa6f]41
[cabf0e8]42 <bridgehead renderas="sect5">Useradd</bridgehead>
[991aa6f]43
[81a73ed8]44 <para>
45 The <command>useradd</command> program uses a collection of default
46 values kept in <filename>/etc/default/useradd</filename>. This file
47 is created in a base LFS installation by the
48 <application>Shadow</application> package. If it has been removed or
49 renamed, the <command>useradd</command> program uses some internal
50 defaults. You can see the default values by running
51 <command>/usr/sbin/useradd -D</command>.
52 </para>
53
54 <para>
55 To change these values, simply modify the
56 <filename>/etc/default/useradd</filename> file as the
57 <systemitem class='username'>root</systemitem> user. An alternative to
58 directly modifying the file is to run <command>useradd</command> as the
59 <systemitem class='username'>root</systemitem> user while supplying the
60 desired modifications on the command line. Information on how to do this
61 can be found in the <command>useradd</command> man page.
62 </para>
[991aa6f]63
64 <bridgehead renderas="sect5">/etc/skel</bridgehead>
65
[81a73ed8]66 <para>
67 To get started, create an
68 <filename class="directory">/etc/skel</filename> directory and make sure it
69 is writable only by the system administrator, usually
70 <systemitem class="username">root</systemitem>. Creating the directory as
71 <systemitem class="username">root</systemitem> is the best way to go.
72 </para>
73
74 <para>
75 The mode of any files from this part of the book that you put in <filename
76 class="directory">/etc/skel</filename> should be writable only by the
77 owner. Also, since there is no telling what kind of sensitive information
78 a user may eventually place in their copy of these files, you should
79 make them unreadable by "group" and "other".
80 </para>
81
82 <para>
83 You can also put other files in
84 <filename class="directory">/etc/skel</filename> and
85 different permissions may be needed for them.
86 </para>
87
88 <para>
89 Decide which initialization files should be provided in every (or most)
90 new user's home directory. The decisions you make will affect what you
91 do in the next two sections, <xref linkend="postlfs-config-profile"/> and
92 <xref linkend="postlfs-config-vimrc"/>. Some or all of those files will be
93 useful for <systemitem class="username">root</systemitem>, any
94 already-existing users, and new users.
95 </para>
96
97 <para>
98 The files from those sections that you might want to place in
99 <filename class="directory">/etc/skel</filename> include
100 <filename>.inputrc</filename>, <filename>.bash_profile</filename>,
101 <filename>.bashrc</filename>, <filename>.bash_logout</filename>,
102 <filename>.dircolors</filename>, and <filename>.vimrc</filename>. If
103 you are unsure which of these should be placed there, just continue to
104 the following sections, read each section and any references provided,
105 and then make your decision.
106 </para>
107
108 <para>
109 You will run a slightly modified set of commands for files which are
110 placed in <filename class="directory">/etc/skel</filename>. Each section
111 will remind you of this. In brief, the book's commands have been written
112 for files <emphasis>not</emphasis> added to <filename class="directory">
113 /etc/skel</filename> and instead just sends the results to the user's
114 home directory. If the file is going to be in <filename class="directory">
115 /etc/skel</filename>, change the book's command(s) to send output there
116 instead and then just copy the file from <filename class="directory">
117 /etc/skel</filename> to the appropriate directories, like <filename
118 class="directory">/etc</filename>, <filename class="directory">~
119 </filename> or the home directory of any other user already in the system.
120 </para>
[991aa6f]121
122 <bridgehead renderas="sect5">When Adding a User</bridgehead>
123
[81a73ed8]124 <para>
125 When adding a new user with <command>useradd</command>, use
126 the <option>-m</option> parameter, which tells
127 <command>useradd</command> to create the user's home directory and
128 copy files from <filename class="directory">/etc/skel</filename> (can be
129 overridden) to the new user's home directory. For example (perform as the
130 <systemitem class="username">root</systemitem> user):
131 </para>
[991aa6f]132
[3597eb6]133<screen role="root"><userinput>useradd -m <replaceable>&lt;newuser&gt;</replaceable></userinput></screen>
[9a67723]134
[b3d9df0]135 <para>
136 If you are sharing a <filename class="directory">/home</filename>
137 or <filename class="directory">/usr/src</filename> with another
138 Linux distro (for example, the host distro used for building LFS), you
139 can create a user with the same UID (and, same primary group GID) to
140 keep the file ownership consistent across the systems. First, on
141 <emphasis>the other distro</emphasis>, get the UID of the user and the
142 GID of the user's primary group:
143 </para>
144
145<screen role="nodump"><userinput>getent passwd <replaceable>&lt;username&gt;</replaceable> | cut -d ':' -f 3,4</userinput></screen>
146
147 <para>
148 The command should output the UID and GID, separated by a colon. Now
149 on the BLFS system, create the primary group and the user:
150 </para>
151
152<screen role="root"><userinput>groupadd -g <replaceable>&lt;GID&gt;</replaceable> <replaceable>&lt;username&gt;</replaceable> &amp;&amp;
153useradd -u <replaceable>&lt;UID&gt;</replaceable> -g <replaceable>&lt;username&gt;</replaceable> <replaceable>&lt;username&gt;</replaceable></userinput></screen>
154
[9a67723]155</sect1>
Note: See TracBrowser for help on using the repository browser.