René's URL Explorer Experiment


Title: Linux 用户和用户组的管理 · Issue #29 · nodejh/nodejh.github.io · GitHub

Open Graph Title: Linux 用户和用户组的管理 · Issue #29 · nodejh/nodejh.github.io

X Title: Linux 用户和用户组的管理 · Issue #29 · nodejh/nodejh.github.io

Description: Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。 用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问;另一方面也可以帮助用户组织文件,并为用户提供安全性保护。 每个用户账号都拥有一个惟一的用户名和各自的口令。 用户在登录时键入正确的用户名和口令后,就能够进入系统和自己的主目录。 关于用户账号的管理,主要有以下几大方面: 用户管理。 用户组管...

Open Graph Description: Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。 用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问;另一方面也可以帮助用户组织文件,并为用户提供安全性保护。 每个用户账号都拥有一个惟一的用户名和各自的口令。 用户在登录时键入正确的用户名和口令后,就能够进入系统...

X Description: Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。 用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问;另一方面也可以帮助用户组织文件,并为用户提供安全性保护。 每个用户账号都拥有一个惟一的用户名和各自的口令。 用户在登录时键入正确的用户名和口令后,就能够进入系统...

Opengraph URL: https://github.com/nodejh/nodejh.github.io/issues/29

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Linux 用户和用户组的管理","articleBody":"Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。\r\n\r\n用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问;另一方面也可以帮助用户组织文件,并为用户提供安全性保护。\r\n\r\n每个用户账号都拥有一个惟一的用户名和各自的口令。\r\n\r\n用户在登录时键入正确的用户名和口令后,就能够进入系统和自己的主目录。\r\n\r\n关于用户账号的管理,主要有以下几大方面:\r\n\r\n+ 用户管理。\r\n+ 用户组管理。\r\n+ 用户账号相关系统文件。\r\n\r\n\r\n## 1. 用户管理\r\n\r\n### 1.1. 添加用户\r\n\r\n```\r\nuseradd 选项 用户名\r\n```\r\n\r\n参数说明:\r\n\r\n+ 选项:\r\n    - -c comment 指定一段注释性描述。\r\n    - -d 目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。\r\n    - -g 用户组 指定用户所属的用户组。\r\n    - -G 用户组,用户组 指定用户所属的附加组。\r\n    - -s Shell文件 指定用户的登录Shell。默认的是 `/bin/bash`。\r\n    - -u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。\r\n+ 用户名:指定新账号的登录名。\r\n\r\n**实例1**\r\n\r\n```\r\n# useradd -d /home/jh -m jh\r\n```\r\n\r\n此命令创建了一个用户 `jh`,其中 `-d` 和 `-m` 选项用来为用户 `jh` 创建一个主目录 `/home/jh`,用户登录服务器之后,就处于该目录。\r\n\r\n创建用户时,如果没有给用户指定用户组,则会自动创建一个同名的用户组。\r\n\r\n**实例2**\r\n\r\n```\r\n# useradd -s /bin/sh -g group -G admin,root nodejh\r\n```\r\n\r\n此命令新建了一个用户 `nodejh`,该用户的登录 Shell 是 `/bin/sh`,它属于 `group` 用户组,同时又属于 `adm` 和 `root` 用户组,其中 `group` 用户组是其主组。\r\n\r\n这里可能新建组:`groupadd group` 及 `groupadd admin`。\r\n\r\n增加用户账号就是在 `/etc/passwd` 文件中为新用户增加一条记录,同时更新其他系统文件如 `/etc/shadow`、 `/etc/group` 等。\r\n\r\n\r\n### 1.2. 删除用户\r\n\r\n如果一个用户的账号不再使用,可以从系统中删除。删除用户账号就是要将/etc/passwd等系统文件中的该用户记录删除,必要时还删除用户的主目录。\r\n\r\n删除一个已有的用户账号使用userdel命令,其格式如下:\r\n\r\n```\r\nuserdel 选项 用户名\r\n```\r\n\r\n常用的选项是-r,它的作用是把用户的主目录一起删除。\r\n\r\n例如:\r\n\r\n```\r\n# userdel jh\r\n```\r\n\r\n此命令删除用户 `jh` 在系统文件中(主要是 `/etc/passwd`、`/etc/shadow`、`/etc/group` 等)的记录,同时删除用户的主目录。\r\n\r\n### 1.3 修改账户\r\n\r\n修改用户账号就是根据实际情况更改用户的有关属性,如用户号、主目录、用户组、登录Shell等。\r\n\r\n修改已有用户的信息使用 `usermod` 命令,其格式如下:\r\n\r\n```\r\nusermod 选项 用户名\r\n```\r\n\r\n常用的选项包括 `-c, -d, -m, -g, -G, -s, -u` 等,这些选项的意义与 `useradd` 命令中的选项一样,可以为用户指定新的资源值。\r\n\r\n另外,有些系统可以使用选项:`-l 新用户名`。这个选项指定一个新的账号,即将原来的用户名改为新的用户名。\r\n\r\n例如:\r\n\r\n```\r\n# usermod -s /bin/ksh -d /home/jh1 –g developer jh\r\n```\r\n\r\n此命令将用户 `jh` 的登录 Shell 修改为 `ksh`,主目录改为 `/home/jh`,用户组改为`developer`。\r\n\r\n\r\n### 1.4 用户口令管理\r\n\r\n用户管理的一项重要内容是用户口令的管理。用户账号刚创建时没有口令,但是被系统锁定,无法使用,必须为其指定口令后才可以使用,即使是指定空口令。\r\n\r\n指定和修改用户口令的 Shell 命令是 `passwd`。超级用户可以为自己和其他用户指定口令,普通用户只能用它修改自己的口令。命令的格式为:\r\n\r\n```\r\npasswd 选项 用户名\r\n```\r\n\r\n可使用的选项:\r\n\r\n+ -l 锁定口令,即禁用账号。\r\n+ -u 口令解锁。\r\n+ -d 使账号无口令。\r\n+ -f 强迫用户下次登录时修改口令。\r\n+ \r\n如果默认用户名,则修改当前用户的口令。\r\n\r\n例如,假设当前用户是 `jh`,则下面的命令修改该用户自己的口令:\r\n\r\n```\r\n$ passwd\r\nOld password:****** \r\nNew password:******* \r\nRe-enter new password:*******\r\n```\r\n\r\n如果是超级用户,可以用下列形式指定任何用户的口令:\r\n\r\n```\r\n# passwd jh\r\nNew password:******* \r\nRe-enter new password:*******\r\n```\r\n\r\n普通用户修改自己的口令时,`passwd 命令会先询问原口令,验证后再要求用户输入两遍新口令,如果两次输入的口令一致,则将这个口令指定给用户;而超级用户为用户指定口令时,就不需要知道原口令。\r\n\r\n为了系统安全起见,用户应该选择比较复杂的口令,例如最好使用8位长的口令,口令中包含有大写、小写字母和数字,并且应该与姓名、生日等不相同。\r\n\r\n为用户指定空口令时,执行下列形式的命令:\r\n\r\n```\r\n# passwd -d jh\r\n```\r\n\r\n此命令将用户 `jh` 的口令删除,这样用户 `jh`  下一次登录时,系统就不再询问口令。\r\n\r\n`passwd` 命令还可以用 `-l(lock)` 选项锁定某一用户,使其不能登录,例如:\r\n\r\n```\r\n# passwd -l jh\r\n```\r\n\r\n## 2. 用户组的管理\r\n\r\n每个用户都有一个用户组,系统可以对一个用户组中的所有用户进行集中管理。不同Linux 系统对用户组的规定有所不同,如 Linux 下的用户属于与它同名的用户组,这个用户组在创建用户时同时创建。\r\n\r\n用户组的管理涉及用户组的添加、删除和修改。组的增加、删除和修改实际上就是对/etc/group文件的更新。\r\n\r\n\r\n### 2.1 添加用户组\r\n\r\n添加用户组使用 `groupadd` 命令,其基本格式如下:\r\n\r\n```\r\ngroupadd 选项 用户组\r\n```\r\n\r\n可以使用的选项有:\r\n+ -g GID 指定新用户组的组标识号(GID)。\r\n+ -o 一般与-g选项同时使用,表示新用户组的GID可以与系统已有用户组的GID相同。\r\n\r\n**实例1**\r\n\r\n```\r\n# groupadd group1\r\n```\r\n\r\n此命令向系统中增加了一个新组 `group1`,新组的组标识号是在当前已有的最大组标识号的基础上加 1。\r\n\r\n**实例2**\r\n\r\n```\r\n# groupadd -g 1001 group2\r\n```\r\n\r\n此命令向系统中增加了一个新组 `group2`,同时指定新组的组标识号是 1001。\r\n\r\n\r\n### 2.2 删除用户组\r\n\r\n如果要删除一个已有的用户组,使用 `groupdel` 命令,其格式如下:\r\n\r\n```\r\ngroupdel 用户组\r\n```\r\n\r\n例如:\r\n\r\n```\r\n# groupdel group1\r\n```\r\n\r\n此命令从系统中删除组group1。\r\n\r\n### 2.3 修改用户组\r\n\r\n修改用户组的属性使用 `groupmod` 命令。其语法如下:\r\n\r\n```\r\ngroupmod 选项 用户组\r\n```\r\n\r\n常用的选项有:\r\n\r\n+ -g GID 为用户组指定新的组标识号。\r\n+ -o 与-g选项同时使用,用户组的新GID可以与系统已有用户组的GID相同。\r\n+ -n 新用户组 将用户组的名字改为新名字\r\n\r\n**实例1**\r\n\r\n```\r\n# groupmod -g 102 group2\r\n```\r\n\r\n此命令将组group2的组标识号修改为102。\r\n\r\n**实例2**\r\n\r\n```\r\n# groupmod –g 10000 -n group3 group2\r\n```\r\n\r\n此命令将组 `group2` 的标识号改为 `10000`,组名修改为 `group3`。\r\n\r\n### 2.4 切换用户组\r\n\r\n如果一个用户同时属于多个用户组,那么用户可以在用户组之间切换,以便具有其他用户组的权限。\r\n\r\n用户可以在登录后,使用命令 `newgrp` 切换到其他用户组,这个命令的参数就是目的用户组。\r\n\r\n例如: \r\n\r\n```\r\n$ newgrp root\r\n```\r\n\r\n这条命令将当前用户切换到 `root` 用户组,前提条件是 `root` 用户组确实是该用户的主组或附加组。\r\n\r\n## 3. 用户账号相关系统文件\r\n\r\n完成用户管理的工作有许多种方法,但是每一种方法实际上都是对有关的系统文件进行修改。\r\n与用户和用户组相关的信息都存放在一些系统文件中,这些文件包括 `/etc/passwd`、`/etc/shadow`、 `/etc/group` 等。\r\n\r\n下面分别介绍这些文件的内容。\r\n\r\n\r\n### 3.1 `/etc/passwd`\r\n\r\nLinux系统中的每个用户都在 `/etc/passwd` 文件中有一个对应的记录行,它记录了这个用户的一些基本属性。\r\n\r\n这个文件对所有用户都是可读的。它的内容类似下面的例子:\r\n\r\n```\r\n# cat /etc/passwd\r\ndnsmasq:x:109:65534:dnsmasq,,,:/var/lib/misc:/bin/false\r\nsshd:x:110:65534::/var/run/sshd:/usr/sbin/nologin\r\npollinate:x:111:1::/var/cache/pollinate:/bin/false\r\nntp:x:112:115::/home/ntp:/bin/false\r\njh:x:1000:1000::/home/jh:\r\n```\r\n\r\n从上面的例子我们可以看到,`/etc/passwd` 中一行记录对应着一个用户,每行记录又被冒号(:)分隔为7个字段,其格式和具体含义如下:\r\n\r\n```\r\n用户名:口令:用户编号:用户组编号:用户注释信息:用户主目录:shell类型\r\n```\r\n\r\n**用户名**\r\n\r\n是代表用户账号的字符串。通常长度不超过8个字符,并且由大小写字母和/或数字组成。登录名中不能有冒号(:),因为冒号在这里是分隔符。为了兼容起见,登录名中最好不要包含点字符(.),并且不使用连字符(-)和加号(+)打头。\r\n\r\n**口令**\r\n\r\n虽然这个字段存放的只是用户口令的加密串,不是明文,但是由于 `/etc/passwd` 文件对所有用户都可读,所以这仍是一个安全隐患。因此,现在许多 Linux 系统(如SVR4)都使用了 shadow 技术,把真正的加密后的用户口令字存放到 `/etc/shadow` 文件中,而在 `/etc/passwd` 文件的口令字段中只存放一个特殊的字符,例如 `x` 或者 `*`。\r\n\r\n**用户编号**\r\n\r\n用户编号是一个整数,系统内部用它来标识用户。\r\n\r\n般情况下它与用户名是一一对应的。如果几个用户名对应的用户标识号是一样的,系统内部将把它们视为同一个用户,但是它们可以有不同的口令、不同的主目录以及不同的登录 Shell 等。\r\n通常用户标识号的取值范围是 `0~65 535`。`0` 是超级用户 `root` 的标识号,`1~99` 由系统保留,作为管理账号,普通用户的标识号从 `100` 开始。在Linux系统中,这个界限是`500`。 \r\n\r\n**用户组编号**\r\n\r\n用户组编号字段记录的是用户所属的用户组。它对应着 `/etc/group` 文件中的一条记录。\r\n\r\n**用户注释信息**\r\n\r\n例如用户的真实姓名、电话、地址等,这个字段并没有什么实际的用途。在不同的 Linux 系统中,这个字段的格式并没有统一。在许多 Linux 系统中,这个字段存放的是一段任意的注释性描述文字,用做 `finger` 命令的输出。\r\n\r\n**用户主目录**\r\n\r\n它是用户在登录到系统之后所处的目录。在大多数系统中,各用户的主目录都被组织在同一个特定的目录下,而用户主目录的名称就是该用户的登录名。各用户对自己的主目录有读、写、执行(搜索)权限,其他用户对此目录的访问权限则根据具体情况设置。\r\n\r\n**shell类型**\r\n\r\n用户登录后,要启动一个进程,负责将用户的操作传给内核,这个进程是用户登录到系统后运行的命令解释器或某个特定的程序,即 Shell。\r\n\r\nShell 是用户与 Linux 系统之间的接口。Linux 的 Shell 有许多种,每种都有不同的特点。常用的有:\r\n\r\n+ sh(Bourne Shell)\r\n+ csh(C Shell)\r\n+ ksh(Korn Shell)\r\n+ tcsh(TENEX/TOPS-20 type C Shell)\r\n+ bash(Bourne Again Shell)\r\n\r\n系统管理员可以根据系统情况和用户习惯为用户指定某个 Shell。如果不指定 Shell,那么系统使用 `sh` 为默认的登录 Shell,即这个字段的值为 `/bin/sh`。而 `/bin/sh` 一般链接到 `/bin/dash`。\r\n\r\n用户的登录 Shell 也可以指定为某个特定的程序(此程序不是一个命令解释器)。\r\n\r\n利用这一特点,我们可以限制用户只能运行指定的应用程序,在该应用程序运行结束后,用户就自动退出了系统。有些Linux 系统要求只有那些在系统中登记了的程序才能出现在这个字段中。\r\n\r\n\r\n### 3.2 `/etc/shadow`\r\n\r\n`/etc/shadow` 中的记录行与 `/etc/passwd` 中的一一对应,它由 `pwconv` 命令根据 `/etc/passwd` 中的数据自动产生。\r\n\r\n它的文件格式与 `/etc/passwd` 类似,由若干个字段组成,字段之间用 `:` 隔开。这些字段是:\r\n\r\n```\r\n登录名:加密口令:最后一次修改时间:最小时间间隔:最大时间间隔:警告时间:不活动时间:失效时间:标志\r\n```\r\n\r\n+ 登录名 是与 `/etc/passwd` 文件中的登录名相一致的用户账号\r\n+ 口令 字段存放的是加密后的用户口令字,长度为13个字符。如果为空,则对应用户没有口令,登录时不需要口令;如果含有不属于集合 `{ ./0-9A-Za-z }` 中的字符,则对应的用户不能登录。\r\n+ 最后一次修改时间 表示的是从某个时刻起,到用户最后一次修改口令时的天数。时间起点对不同的系统可能不一样。例如在 SCO Linux 中,这个时间起点是1970年1月1日。\r\n+ 最小时间间隔 指的是两次修改口令之间所需的最小天数。\r\n+ 最大时间间隔 指的是口令保持有效的最大天数。\r\n+ 警告时间 字段表示的是从系统开始警告用户到用户密码正式失效之间的天数。\r\n+ 不活动时间 表示的是用户没有登录活动但账号仍能保持有效的最大天数。\r\n+ 失效时间 字段给出的是一个绝对的天数,如果使用了这个字段,那么就给出相应账号的生存期。期满后,该账号就不再是一个合法的账号,也就不能再用来登录了。\r\n\r\n### 3.3 `/etc/group`\r\n\r\n用户组的所有信息都存放在 `/etc/group` 文件中。\r\n\r\n用户分组是Linux 系统中对用户进行管理及控制访问权限的一种手段。\r\n\r\n每个用户都属于某个用户组;一个组中可以有多个用户,一个用户也可以属于不同的组。\r\n\r\n当一个用户同时是多个组中的成员时,在 `/etc/passwd` 文件中记录的是用户所属的主组,也就是登录时所属的默认组,而其他组称为附加组。\r\n\r\n用户要访问属于附加组的文件时,必须首先使用 `newgrp` 命令使自己成为所要访问的组中的成员。\r\n用户组的所有信息都存放在 `/etc/group` 文件中。此文件的格式也类似于 `/etc/passwd` 文件,由冒号 `:` 隔开若干个字段,这些字段有:\r\n\r\n```\r\n组名:口令:组标识号:组内用户列表\r\n```\r\n\r\n+ 组名 是用户组的名称,由字母或数字构成。与 `/etc/passwd` 中的登录名一样,组名不应重复。\r\n+ 口令 字段存放的是用户组加密后的口令字。一般 Linux 系统的用户组都没有口令,即这个字段一般为空,或者是 `*`。\r\n+ 组标识号 与用户标识号类似,也是一个整数,被系统内部用来标识组。\r\n+ 组内用户列表 是属于这个组的所有用户的列表,不同用户之间用逗号 `,` 分隔。这个用户组可能是用户的主组,也可能是附加组。\r\n\r\n## 4. 伪用户 psuedo users\r\n\r\n统中有一类用户称为伪用户(psuedo users)。\r\n\r\n这些用户在 `/etc/passwd` 文件中也占有一条记录,但是不能登录,因为它们的登录Shell为空。它们的存在主要是方便系统管理,满足相应的系统进程对文件属主的要求。\r\n\r\n常见的伪用户如下所示:\r\n\r\n+ bin 拥有可执行的用户命令文件 \r\n+ sys 拥有系统文件 \r\n+ adm 拥有帐户文件 \r\n+ uucp UUCP使用 \r\n+ lp lp或lpd子系统使用 \r\n+ nobody NFS使用\r\n\r\n\r\n除了上面列出的伪用户外,还有许多标准的伪用户,例如:`audit`、`cron`、`mail` `usenet` 等,它们也都各自为相关的进程和文件所需要。\r\n\r\n\r\n\r\n## 5. 添加批量用户\r\n\r\n\r\n添加和删除用户对每位 Linux 系统管理员都是轻而易举的事,比较棘手的是如果要添加几十个、上百个甚至上千个用户时,我们不太可能还使用 `useradd` 一个一个地添加,必然要找一种简便的创建大量用户的方法。Linux系统提供了创建大量用户的工具,可以让您立即创建大量用户,方法如下:\r\n\r\n**a) 先编辑一个文本用户文件**\r\n\r\n每一列按照 `/etc/passwd` 文件的格式书写,要注意每个用户的用户名、UID、宿主目录都不可以相同,其中密码栏可以留做空白或输入 `x` 号。一个范例文件 user.txt 内容如下:\r\n\r\n```\r\nuser001::600:100:user:/home/user001:/bin/bash\r\nuser002::601:100:user:/home/user002:/bin/bash\r\nuser003::602:100:user:/home/user003:/bin/bash\r\nuser004::603:100:user:/home/user004:/bin/bash\r\nuser005::604:100:user:/home/user005:/bin/bash\r\nuser006::605:100:user:/home/user006:/bin/bash\r\n```\r\n\r\n**b) 导入用户**\r\n\r\n以 `root` 身份执行命令 `/usr/sbin/newusers`,从刚创建的用户文件user.txt中导入数据,创建用户:\r\n\r\n```\r\n# newusers \u003c user.txt\r\n```\r\n\r\n然后可以执行 `cat /etc/passwd` 等命令检查 `/etc/passwd` 文件是否已经出现这些用户的数据,并且用户的宿主目录是否已经创建。\r\n\r\n**c) 解码密码**\r\n\r\n将 `/etc/shadow` 产生的 shadow 密码解码,然后回写到 `/etc/passwd` 中,并将 `/etc/shadow` 的shadow密码栏删掉。这是为了方便下一步的密码转换工作,即先取消 shadow password 功能。\r\n\r\n执行命令 `/usr/sbin/pwunconv`:\r\n\r\n```\r\n# pwunconv\r\n```\r\n\r\n**d) 编辑密码文件**\r\n\r\n编辑每个用户的密码对照文件,范例文件 passwd.txt 内容如下:\r\n\r\n```\r\nuser001:密码\r\nuser002:密码\r\nuser003:密码\r\nuser004:密码\r\nuser005:密码\r\nuser006:密码\r\n```\r\n\r\n**e) 创建用户密码**\r\n\r\n创建用户密码,`chpasswd` 会将经过 `/usr/bin/passwd` 命令编码过的密码写入 `/etc/passwd` 的密码栏。\r\n\r\n```\r\n# chpasswd \u003c passwd.txt\r\n```\r\n\r\n**f) 编码密码**\r\n\r\n确定密码经编码写入 `/etc/passwd` 的密码栏后,执行命令 `/usr/sbin/pwconv` 将密码编码为 `shadow password`,并将结果写入 `/etc/shadow`。\r\n\r\n```\r\n# pwconv\r\n```\r\n\r\n这样就完成了大量用户的创建了,之后就可以到 `/home` 下检查这些用户宿主目录的权限设置是否都正确,并登录验证用户密码是否正确。\r\n\r\n## 6. 赋予用户 root 权限\r\n\r\n如果普通用户不在 `/etc/sudoers` 文件中,则使用 `sudo` 命令的时候就会报错,如:\r\n\r\n```\r\n$ sudo apt-get install git\r\njh is not in the sudoers file.  This incident will be reported.\r\n```\r\n\r\n首先看看 `/etc/suders` 文件的内容,里面有如下几行:\r\n\r\n```\r\n# User privilege specification\r\nroot\tALL=(ALL:ALL) ALL\r\n\r\n# Members of the admin group may gain root privileges\r\n%admin ALL=(ALL) ALL\r\n\r\n# Allow members of group sudo to execute any command\r\n%sudo\tALL=(ALL:ALL) ALL\r\n```\r\n\r\n其中,`root    ALL=(ALL) ALL`\r\n\r\n+ `root` 表示被授权的用户,这里是 root 用户。\r\n+ 第一个ALL表示所有计算机。\r\n+ 第二个ALL表示所有用户。\r\n+ 第三个ALL表示所有命令。\r\n\r\n全句的意思是:授权根用户在所有计算机上以所有用户的身份运行所有文件。\r\n\r\n`%admin ALL=(ALL) ALL` 同上面一样,只不过被授权的成了 `admin` 这个组。\r\n\r\n所以在 `root\tALL=(ALL:ALL) ALL` 下面加一行:\r\n\r\n```\r\njh ALL=(ALL:ALL) ALL\r\n```\r\n\r\n然后 `jh` 用户登录后,使用 `sudo` 就可以获得 root 权限了。\r\n\r\n当然,在其他两个地方添加类似的内容,也是可以的。\r\n\r\n## 7. 其他\r\n\r\n+ whoami 查看当前用户\r\n+ id users 查看用户编号及用户组编号\r\n\r\n\r\n","author":{"url":"https://github.com/nodejh","@type":"Person","name":"nodejh"},"datePublished":"2017-02-10T08:27:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/29/nodejh.github.io/issues/29"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4307857e-a5cc-e73e-4f11-ba79eecfb2da
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9A34:9E656:414D106:559D8BC:6992E83B
html-safe-nonce5478059235a463ff3b4dc22161ee7eca76169d67b0f1b1089f4a7e2073de9e9f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTM0OjlFNjU2OjQxNEQxMDY6NTU5RDhCQzo2OTkyRTgzQiIsInZpc2l0b3JfaWQiOiI3MTk0MzU1OTc1MzM1MzcyODU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac59a0911b0e3c60814bd0003d4101b2ad3609629f75ec98b9b32b5fda9415f260
hovercard-subject-tagissue:206735704
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejh/nodejh.github.io/29/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a18d28ec7ee621ff514a1db8561b0573a9216e9cc33f0d31aaffe16ae664df71/nodejh/nodejh.github.io/issues/29
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a18d28ec7ee621ff514a1db8561b0573a9216e9cc33f0d31aaffe16ae664df71/nodejh/nodejh.github.io/issues/29
og:image:altLinux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。 用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问;另一方面也可以帮助用户组织文件,并为用户提供安全性保护。 每个用户账号都拥有一个惟一的用户名和各自的口令。 用户在登录时键入正确的用户名和口令后,就能够进入系统...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenodejh
hostnamegithub.com
expected-hostnamegithub.com
None42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b
turbo-cache-controlno-preview
go-importgithub.com/nodejh/nodejh.github.io git https://github.com/nodejh/nodejh.github.io.git
octolytics-dimension-user_id10287125
octolytics-dimension-user_loginnodejh
octolytics-dimension-repository_id45253813
octolytics-dimension-repository_nwonodejh/nodejh.github.io
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id45253813
octolytics-dimension-repository_network_root_nwonodejh/nodejh.github.io
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release84dcb133269e3cfe6e0296cc85fbacb92cae92bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejh/nodejh.github.io/issues/29#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejh%2Fnodejh.github.io%2Fissues%2F29
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejh%2Fnodejh.github.io%2Fissues%2F29
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejh%2Fnodejh.github.io
Reloadhttps://github.com/nodejh/nodejh.github.io/issues/29
Reloadhttps://github.com/nodejh/nodejh.github.io/issues/29
Reloadhttps://github.com/nodejh/nodejh.github.io/issues/29
nodejh https://github.com/nodejh
nodejh.github.iohttps://github.com/nodejh/nodejh.github.io
Notifications https://github.com/login?return_to=%2Fnodejh%2Fnodejh.github.io
Fork 34 https://github.com/login?return_to=%2Fnodejh%2Fnodejh.github.io
Star 264 https://github.com/login?return_to=%2Fnodejh%2Fnodejh.github.io
Code https://github.com/nodejh/nodejh.github.io
Issues 59 https://github.com/nodejh/nodejh.github.io/issues
Pull requests 0 https://github.com/nodejh/nodejh.github.io/pulls
Actions https://github.com/nodejh/nodejh.github.io/actions
Projects 0 https://github.com/nodejh/nodejh.github.io/projects
Wiki https://github.com/nodejh/nodejh.github.io/wiki
Security 0 https://github.com/nodejh/nodejh.github.io/security
Insights https://github.com/nodejh/nodejh.github.io/pulse
Code https://github.com/nodejh/nodejh.github.io
Issues https://github.com/nodejh/nodejh.github.io/issues
Pull requests https://github.com/nodejh/nodejh.github.io/pulls
Actions https://github.com/nodejh/nodejh.github.io/actions
Projects https://github.com/nodejh/nodejh.github.io/projects
Wiki https://github.com/nodejh/nodejh.github.io/wiki
Security https://github.com/nodejh/nodejh.github.io/security
Insights https://github.com/nodejh/nodejh.github.io/pulse
New issuehttps://github.com/login?return_to=https://github.com/nodejh/nodejh.github.io/issues/29
New issuehttps://github.com/login?return_to=https://github.com/nodejh/nodejh.github.io/issues/29
Linux 用户和用户组的管理https://github.com/nodejh/nodejh.github.io/issues/29#top
https://github.com/nodejh
https://github.com/nodejh
nodejhhttps://github.com/nodejh
on Feb 10, 2017https://github.com/nodejh/nodejh.github.io/issues/29#issue-206735704
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.