LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-27-2016, 09:27 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,166
Blog Entries: 4

Rep: Reputation: 131Reputation: 131
end user fails to switch to a newgrp


So I'm working from an example, where as a normal user, uses the following command:

Code:
newgrp
Then create a file, with touch, then list the file and see that the new group has permissions to that file.

The only issue is that when I do this, newgrp, I get prompted for the passwd and then type the user's passwd and get Invalid Password.

Code:
-sh-4.1$ newgrp testing 
Password: 
Invalid password.  
-sh-4.1$ newgrp testing 
Password:  
Invalid password.
If I add that user to that group

Code:
usermod -g testing jbaxter
Then I su to that user (jbaxter) and them I'm able to use the newgrp command successfully.

So I'm thinking the example that I'm looking at is bad and you have to add the user to that group first before issuing the newgrp command, correct?
 
Old 01-27-2016, 10:05 PM   #2
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,080

Rep: Reputation: Disabled
creating groups and user and passwd is a root dude only thing, you have to go su or su - or sudo in order to create. change, these items.

when you try to use newgrp and it asks for password it is talking about the root user pass word not user pass word.

when you are in a user login and you su then enter password you've essentially just bypassed typing sudo newgrp then it'd prob still ask you for a pass word, all depending on how you have your sudo user(s) set up in the suduers file, in /etc. you can fix it so you do not have to use a pass word on sudo <command> .

what you did by using su first is just put yourself into superUser Mode that has root access is all, instead of loging out then back in as root.

too you mayhave to ensure that the user is attached to the group your working with newgrp is new to me. though it is logical that one has to be attached to a group before they can log into it as I just read about his newgrp command a little bit . but just the same try using root pass word and see if that is it.

by what this reads is looks just like using su or sudo but not su - then a password for vaildate the login, giving that person the rights that this group has .. but not on a file, yes just within that other person login session.

when you touch filename it automaticly gives it the one who created it ownership and there group attached to it.

this is interesting I've never seen this newgrp before...

so basicly forget everything (almost everything I just said) it seems logically you'd be getting asked for the password of that group. but again the group itself and not a file attached to that group.

Quote:
newgrp is used to change the current group ID during a login session.
If the optional - flag is given, the users environment will be reini-
tialized as though the user had logged in, otherwise the current envi-
ronment, including current working directory, remains unchanged.

Last edited by BW-userx; 01-27-2016 at 10:23 PM.
 
Old 01-27-2016, 10:27 PM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,166
Blog Entries: 4

Original Poster
Rep: Reputation: 131Reputation: 131
Quote:
Originally Posted by BW-userx View Post
creating groups and user and passwd is a root dude only thing, you have to go su or su - or sudo in order to create. change, these items
Really? I think newgrp command throws a wrench into this statement. I agree you have to be root/sudo/wheel to run usermod, useradd or userdel, however the example for newgrp doesn't going into detail who's passwd has to be entered when this command is issued.

Quote:
Originally Posted by BW-userx View Post
when you try to use newgrp and it asks for password it is talking about the root user pass word not user pass word.
From the newgrp man page

Quote:
If not root, the user will be prompted for a
password if she does not have a password (in /etc/shadow if this user has an entry
in the shadowed password file, or in /etc/passwd otherwise) and the group does, or
if the user is not listed as a member and the group has a password. The user will be
denied access if the group password is empty and the user is not listed as a
member

Quote:
Originally Posted by BW-userx View Post

by what this reads is looks just like using su or sudo but not su - then a password for vaildate the login, giving that person the rights that this group has .. but not on a file, yes just within that other person login session.
I got it to work by su -l jbaxter and also making sure jbaxter was in the group and then I was able to use newgrp testing and the file I created has the group testing.
 
Old 01-28-2016, 06:37 AM   #4
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,080

Rep: Reputation: Disabled
Quote:
Originally Posted by JockVSJock View Post
Really? .
that newgrg threw me, just the word new then grp made me think it was a command to create a new group, then after I wrote what I did, then looked further into it, then it was time to catch the last bus, and that took precedence over what I was typing in here, but,

by what I see it is to log into a group to gain group privages, nothing more. it acts just as if one is loging into su, and by using the - switch it puts them into their own home, if not used then they stay in the user they are in home enviroment. just like loging in to
Code:
su -
that gets the person back to root home and enviroment, where as just
Code:
su
gets a person root privages, keeping them in the users home and enviroment that they are in when they logged in as su.

So when one uses this newgrp they have to specify the group they are wanting to login to. it has nothing to do with creating a file and what group it is attached to.

the group itself is then set up with permissions to govern what that user can and cannot do.

real world use would then be to give others root privages but not all of them, it is to limit what they can do.

it is the group that has a password, therefor it is a group password attached to that group one is trying to sign into.

group password

limit privages to a group


newgrp examples


Command Aliases


IF you want to limit what someone can do with a file or directory use sticky bits1 sticky bits 2 sticky bits 3

Last edited by BW-userx; 01-28-2016 at 06:59 AM.
 
  


Reply

Tags
newgrp, usermod


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] OpenLDAP user unable to change group via newgrp loadedmind Linux - Server 2 07-15-2014 04:00 PM
Ebay Hackers switch from Windows to Linux OS , the end is near for microsoft !! lboog123 Linux - News 4 10-15-2007 08:50 PM
X11R72: configure fails due to unexpected end of file? ichrispa Linux - Software 0 07-28-2007 08:00 AM
ffmpeg fails to detect missing end of avi-file batchman Linux - Software 1 08-21-2004 03:44 PM
9.1 install fails at end??? magicvash Mandriva 6 09-29-2003 09:28 AM


All times are GMT -5. The time now is 04:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration