当前位置: 首页>>技术教程>>正文


users – Ubuntu 中用户的默认组?

问题描述

使用安装脚本安装了 HP Linux Imaging and Printing 并且某些东西崩溃了。现在我只是我自己组和 lp 的成员。

例如,Ubuntu 12.10 中用户的默认组是哪些? Same as this ?

出于好奇,有没有地方记录这些信息?例如,一些日志文件显示我的用户在上次启动时所在的组?此信息(哪些组是默认的)是否记录在某处?

最佳思路

A) 简答

默认组;说 user123,在全新安装时 – (在终端中使用命令 groups):

user123 adm cdrom sudo dip plugdev lpadmin sambashare

给出与 11.04 的差异为

获取/查看默认值。也可能对其他各种人有用;做:

sudo grep user-setup /var/log/installer/syslog


B) 恢复默认组

(添加这个使其更完整)

1. 识别群体

我总是设置 root 密码,但如果你没有使用 live CD、live USB、其他安装等来访问文件。

如果您已设置 root 密码(即通过):

sudo passwd root

并失去了 sudo 权限,请执行以下操作:

su - root
grep user-setup /var/log/installer/syslog

给你即

... user-setup: pwconv: failed to change the mode of /etc/passwd- to 0600
... user-setup: Shadow passwords are now on.
... user-setup: Adding user `user123' ...
... user-setup: Adding new group `user123' (1000) ...
... user-setup: Adding new user `user123' (1000) with group `user123' ...
... user-setup: Creating home directory `/home/user123' ...
... user-setup: Copying files from `/etc/skel' ...
... user-setup: addgroup: The group `lpadmin' already exists as a system group. Exiting.
... user-setup: Adding group `sambashare' (GID 124) ...
... user-setup: Done.
... user-setup: Adding user `user123' to group `adm' ...
... user-setup: Adding user user123 to group adm
... user-setup: Done.
... user-setup: Adding user `user123' to group `cdrom' ...
... user-setup: Adding user user123 to group cdrom
... user-setup: Done.
... user-setup: Adding user `user123' to group `dip' ...
... user-setup: Adding user user123 to group dip
... user-setup: Done.
... user-setup: Adding user `user123' to group `lpadmin' ...
... user-setup: Adding user user123 to group lpadmin
... user-setup: Done.
... user-setup: Adding user `user123' to group `plugdev' ...
... user-setup: Adding user user123 to group plugdev
... user-setup: Done.
... user-setup: Adding user `user123' to group `sambashare' ...
... user-setup: Adding user user123 to group sambashare
... user-setup: Done.
... user-setup: adduser: The group `debian-tor' does not exist.
... user-setup: Adding user `user123' to group `sudo' ...
... user-setup: Adding user user123 to group sudo
... user-setup: Done.
... ubiquity: Removing user-setup ...
... ubiquity: Purging configuration files for user-setup ...

或者:

su - root
grep "user-setup: Adding user user123 to group" /var/log/installer/syslog | cut -d' ' -f11

其中产生:

adm
cdrom
dip
lpadmin
plugdev
sambashare
sudo

(不知道为什么 dip 突然通过安装成为默认组。与 dialout 被删除有关吗?)


2.a 更新组 – 使用 “内置” 根访问

所以,以 root 身份向用户添加组,即用户 user123

usermod -a -G adm,cdrom,lpadmin,sudo,sambashare,dip,plugdev user123

其中( Somewhat outdated on 12.10 ):

adm         Monitor system logs
cdrom       Use CD-ROM drives
lpadmin     Configure printers
sudo        administer the system, ...
sambashare  Share files with the local network
dip         Connect to the Internet using a modem
plugdev     Access external storage devices

您可能需要的一些额外功能:(通过 root@YOURPC:~# id -nG user123 检查您拥有的内容)

dialout     ttyS*/Serial/COM1,COM2 ...
vboxusers   Virtual Box
user123     Your own group

如果你想; double-check /etc/group ,即(这里有一些额外内容):

root@YOURPC:~# grep user123 /etc/group

adm:x:4:user123
audio:x:29:user123,timidity,pulse
video:x:44:user123
lp:x:7:user123
dialout:x:20:user123
cdrom:x:24:user123
sudo:x:27:user123
dip:x:30:user123
plugdev:x:46:user123
lpadmin:x:107:user123
user123:x:1000:
sambashare:x:124:user123
vboxusers:x:127:user123
autologin:x:1001:user123

作为另一种选择,可以启动到救援模式并

mount -o remount,rw /
usermod -G adm,cdrom,lpadmin,sudo,sambashare,dip,plugdev user123

注销并登录。应该更新组。


2.b 更新组 – 使用来自 Live-CD 等的 root 访问权限。

xxx 此处是运行实时版本时 file-system 的安装位置,即 /media/foo

使用 vigr 手动编辑文件 /xxx/etc/group 并添加用户,如前面的列表所示。

或者;只将用户添加到 sudo;如:

sudo:x:27:user123

通过使用 sudo 执行 usermod 命令启动到您的安装和更新:

sudo usermod -a -G adm,cdrom,lpadmin,sudo,sambashare,dip,plugdev user123

注销并登录。应该更新组。


双重注意:从 11.10 开始, admin 不再是 Ubuntu 的一部分,取而代之的是 sudo

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/12127.html,未经允许,请勿转载。