Ubuntu中用户的默认组?


27

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

例如,在Ubuntu 12.10中,用户的默认组是哪些?一样吗?

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

Answers:


43

A)简短答案

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

user123 adm cdrom sudo dip plugdev lpadmin sambashare

从11.04获得差异

  • admin 被替换为 sudo
  • dialout 已移除
  • dip 被添加。

获取/查看默认值。可能也会为其他各种人工作;做:

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


B)恢复默认组

(添加此内容使其更完整)

1.确定群体

我总是设置root密码,但是如果您还没有使用实时CD,实时USB,其他安装程序等来获取文件。

如果你一组根密码(IE):

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身份向用户添加组,即user user123

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

位置(在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

如果你想; 仔细检查/ 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这是运行实时版本(即)时挂载文件系统的位置/media/foo

/xxx/etc/group使用vigr手动编辑文件,并按照前面的清单添加用户。

要么; 仅将用户添加到sudo; 如:

sudo:x:27:user123

通过执行以下usermod命令来启动安装并进行更新sudo

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

注销并登录。组应更新。


请注意:admin从11.10开始,不再支持Ubuntu sudo


2
谢谢。您的答案非常详细,对于不小心弄乱了用户组的人非常有用。
rcourtna

@rcourtna:谢谢。我就是这样自己结束的。在我找到sudo cat /var/log/installer/syslog | grep user-setup:) 之前进行了一些黑客活动
13年

注意:命令usermod -G adm,cdrom,lpadmin,sudo,sambashare,dip,plugdev (第2.a节)包含错误:usermod需要指定用户。命令应如下所示:(usermod -G adm,cdrom,lpadmin,sudo,sambashare,dip,plugdev user123 我已通过编辑修复了该错误,但由于某些原因我的更改被拒绝。)
dess 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.