SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The "groups" command should show what group memberships a user has.
A user is a member of groups when explicitly associated with them in /etc/groups (e.g. the plugdev line shows chongming is a member). Also users have a default group which is specified in /etc/passwd.
The first four fields of /etc/passwd should be something like:
user:x(or encrypted password if no shadow file):UID:GID:
Where:
user = the User (e.g. chongming)
UID = the User ID (number)
GID = the Group ID (number).
You can compare the GID number against the GID shown in 3rd field of /etc/group to determine which group that GID refers to.
The fact that "groups chongming" shows only plugdev would lead me to believe the GID for user "chongming" is 83. If so there is no reason to also have "chongming" in /etc/groups as it is redundant.
Typing "groups" without user name shows you the groups for the user that executed the command. Before executing the command type "whoami" (NOT "who am i") to verify you're the user you think you are. This shows your effective user rather than real user which might be different if you'd done an "su".
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
The group command without a parameter is returning the current user's groups. When a username is passed as a parameter the /etc/group and the /etc/passwd files are looked at and group memberships are displayed from those. There may be a difference in the two as there may be console default groups in the /etc/login.defs file. This is accessed when logging into the console via login. Slackware is setup to automatically join certain groups - this is from the /etc/login.defs file :
Code:
#
# List of groups to add to the user's supplementary group set
# when logging in on the console (as determined by the CONSOLE
# setting). Default is none.
#
# Use with caution - it is possible for users to gain permanent
# access to these groups, even when not logged in on the console.
# How to do it is left as an exercise for the reader...
#
# Most of these groups are self-explanatory, with the possible
# exception of "plugdev", which allows the use of plugable devices
# such as USB storage (flash memory sticks, most digital cameras,
# some media players, and other devices), many IEEE1394 (sometimes
# called "FireWire") devices, and more. For plugdev devices, the
# use of HAL is required. HAL also helps users interact with
# hardware in the other groups below (and other hardware) more
# easily as well, so it's a good idea to turn HAL on for any
# machine that will be used from the console.
#
# Note that users are added to these default groups only when
# logging into a shell with /bin/login, not when using a login
# manager such as kdm. In that case, users who should have
# hardware access must be added to the appropriate groups
# when the user is added with adduser or useradd, or by editing
# /etc/group directly.
#
CONSOLE_GROUPS floppy:audio:cdrom:video:plugdev
This explains the difference. It may also cause confusion when starting at runlevel 4 as the login process is different and the supplementary groups may not be joined. Because of this I'd recommend adding a user to the supplementary groups in the /etc/group file.
Last edited by bgeddy; 11-04-2008 at 10:14 AM.
Reason: Further information
Hi,
thanks for the explaination.So that means the group which i'm in when i just type the command: groups, its shows users floppy audio video cdrom.
I assume these groups are set up by slackware in default. Am i right.
No. You are transiently added to these groups in /etc/login.defs when in runlevel 3 (ie you start from a terminal and type startx to launch X). You should add yourself permanently using
Code:
# gpasswd -a chongming audio
# gpasswd -a chongming video
# gpasswd -a chongming floppy
# gpasswd -a chongming cdrom
# gpasswd -a chongming plugdev
You should probably change your initial group before you do that though -- you are currently have the plugdev group as your initial group. You *should* have the users group as your initial group. Try the following command BEFORE doing the gpasswd stuff above, and THEN do all of the gpasswd stuff above.
No. You are transiently added to these groups in /etc/login.defs when in runlevel 3 (ie you start from a terminal and type startx to launch X). You should add yourself permanently using
Interesting - Is this slackware specific? I don't see anything about adding groups (other than setting minimum and maximum GID value) in /etc/login.defs on my RHEL and Fedora systems.
Also I would have suggested use of "usermod -G" instead of gpasswd but either would work.
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
Quote:
Interesting - Is this slackware specific? I don't see anything about adding groups (other than setting minimum and maximum GID value) in /etc/login.defs on my RHEL and Fedora systems.
The supplementary groups are listed with CONSOLE_GROUPS as their label in /etc/login.defs and Debian Etch 4.0 has them set to floppy:audio:cdrom but commented out in the file.
Quote:
Also I would have suggested use of "usermod -G" instead of gpasswd but either would work.
A lot of people misread the useage of this command not realizing that the groups givien will override the previous settings i.e. it's not accumulative whereas gpasswd -a -g user group is. Slackware people tend to recommend the gpasswd way because of this.
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
Quote:
My lone Debian box can't do it either but that version is a couple of years old.
I don't know if there's a connection with having the usermod -a flag and a lack of supplementary groups in login.defs. This had got me cycling through some VM's I rarely look at. Centos 5.2 server has no CONSOLE_GROUPS nor does PCLinux 2007 but Ubuntu 8 server does - possibly the Debian/RH connections there. Also makes me wish my additional memory had arrived as running multiple VM's soon slows stuff down ! Well - interesting stuff I suppose
The Debian box has CONSOLE_GROUPS keyword but it is commented out and never had any groups assigned to it. But then again on that one I never got X running because it is an HP PA-RISC (HPPA) box. (Debian has a port for HPPA so I didn't have to roll my own.)
Not surprising about CentOS - It is built by compiling from RHEL source.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.