LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-14-2012, 12:59 PM   #1
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Rep: Reputation: Disabled
how can i assign a group to existing user


Hello to all

I tried to change group to existing linux user. i couldn't.

>> Add an existing user to a group using usermod >>

PHP Code:
[root@localhost ~]# useradd   test1
[root@localhost ~]# cd /home/test1
[root@localhost xx]# ls -al
total 36
drwx
------   2    test1    test1   4096  Nov 15 00:05 .
drwxr-xr-x  22  root     root   4096  Nov  15 00:05 .. 
here

>> I tried to change group from test1 to dba >>

PHP Code:
[root@localhost xx]# usermod -g  dba  test1
[root@localhost xx]# ls -al
total 36
drwx
------   2 test1    test1   4096 Nov 15 00:05 .
drwxr-xr-x  22 root root 4096 Nov 15 00:05 .. 

2. Is there any possibilities to find assigned group details
to a user ? i mean , (Group => primary or secondery)

Regards
Thiyagusham.G
 
Old 11-14-2012, 01:22 PM   #2
mandyapenguin
Member
 
Registered: Nov 2011
Location: India
Distribution: RedHat, Cent OS, Fedora, Debian, Ubuntu
Posts: 106

Rep: Reputation: Disabled
To find out group(s) use id command
Code:
id username

man id
You can add seconday group(s) to existing user using
Code:
usermod -a -G groupname username
If you want to change primary group use
Code:
usermod -G groupname -g groupname username
 
Old 11-14-2012, 01:33 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://rute.2038bug.com/index.html.gz
 
Old 11-14-2012, 04:57 PM   #4
hgsolari
LQ Newbie
 
Registered: Sep 2007
Distribution: debian
Posts: 27

Rep: Reputation: 17
Hello
I find your question a little bit confusing.
usermod modifies the group of the user, but then you check the files of the user and, certainly, the ownership did not change as you have only modified /etc/passwd in essence.

Just complete your work
chown -R test1:dba /home/test1

the -R means recursive.

Hernan

Quote:
Originally Posted by thiyagusham View Post
Hello to all

I tried to change group to existing linux user. i couldn't.

>> Add an existing user to a group using usermod >>

PHP Code:
[root@localhost ~]# useradd   test1
[root@localhost ~]# cd /home/test1
[root@localhost xx]# ls -al
total 36
drwx
------   2    test1    test1   4096  Nov 15 00:05 .
drwxr-xr-x  22  root     root   4096  Nov  15 00:05 .. 
here

>> I tried to change group from test1 to dba >>

PHP Code:
[root@localhost xx]# usermod -g  dba  test1
[root@localhost xx]# ls -al
total 36
drwx
------   2 test1    test1   4096 Nov 15 00:05 .
drwxr-xr-x  22 root root 4096 Nov 15 00:05 .. 

2. Is there any possibilities to find assigned group details
to a user ? i mean , (Group => primary or secondery)

Regards
Thiyagusham.G
 
1 members found this post helpful.
Old 11-15-2012, 12:02 AM   #5
khanfiroj123
LQ Newbie
 
Registered: Nov 2006
Posts: 1

Rep: Reputation: 1
Ya Right hgsolari

There is two different things you expected

1. To change Owner of group of Folder
2. To change Primary group of User

for 1.

[root@localhost xx]# usermod -g dba test1
[root@localhost xx]# ls -al
total 36
drwx------ 2 test1 test1 4096 Nov 15 00:05 .
drwxr-xr-x 22 root root 4096 Nov 15 00:05 ..

---->
[root@localhost xx]# ls -al
total 36
drwx------ 2 test1 test1 4096 Nov 15 00:05 .
drwxr-xr-x 22 root root 4096 Nov 15 00:05 ..


[root@localhost xx]# chown -R test1:dba test1


for 2

[root@localhost xx]# usermod -g dba test1

Here -g used for to add 'dba' as secondary group in user test1

[root@localhost xx]# usermod -G dba test1

[root@localhost xx]# cat /etc/group | grep -i test1

[root@localhost xx]# mkdir /home/test1/test

[root@localhost xx]# ls -l /home/test1/.

drwxr-xr-x xx test1 dba xxxx xxx xx xx:xx test


Quote:
Originally Posted by hgsolari View Post
Hello
I find your question a little bit confusing.
usermod modifies the group of the user, but then you check the files of the user and, certainly, the ownership did not change as you have only modified /etc/passwd in essence.

Just complete your work
chown -R test1:dba /home/test1

the -R means recursive.

Hernan
 
1 members found this post helpful.
Old 11-15-2012, 12:30 AM   #6
sarath@slashroot.in
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Rep: Reputation: Disabled
Hi,

In linux by default when a user is created a group with that users name is also created, and that user will be member of that group.

So if modifying groups for a user didn't work with commands. Then you can simply go to /etc/group file add the user to the required group.
Users are added in group file coma separated, you can easily do that by referring to previous entries in that file added by system.

Thanks...
 
Old 11-15-2012, 11:37 AM   #7
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Original Poster
Rep: Reputation: Disabled
@ mandyapenguin ,sarath ,khanfiroj123 , hgsolari , Habitual

Really i am getting useful information from here ..
Thanks for kind reply to all;

Regards
Thiyagusham.G
 
Old 11-15-2012, 11:45 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,520

Rep: Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944Reputation: 7944
Quote:
Originally Posted by sarath@slashroot.in View Post
Hi,
In linux by default when a user is created a group with that users name is also created, and that user will be member of that group.

So if modifying groups for a user didn't work with commands. Then you can simply go to /etc/group file add the user to the required group.
Users are added in group file coma separated, you can easily do that by referring to previous entries in that file added by system.
Editing a system-wide file such as /etc/group is a dangerous thing, and should only be done as a last resort. The usermod command is the way to go, or you can even use a GUI tool, provided with most distros (for example openSUSE has YAST).
 
1 members found this post helpful.
Old 11-15-2012, 12:22 PM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
sudo usermod -g  dba  test1
sudo groups test1
 
1 members found this post helpful.
Old 11-23-2012, 12:20 PM   #10
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Original Poster
Rep: Reputation: Disabled
@ Hi to all ;

How can write it?
I am creating user today. After 60 days , user account should be expired.
For ex : user active on 01-01-2012 end of march 2 account will be expired
 
Old 11-23-2012, 12:39 PM   #11
mandyapenguin
Member
 
Registered: Nov 2011
Location: India
Distribution: RedHat, Cent OS, Fedora, Debian, Ubuntu
Posts: 106

Rep: Reputation: Disabled
Did you read your another thread?
Code:
chage --help
man chage
To set account expiry date
Code:
chage -E "2012-03-02" username
 
1 members found this post helpful.
Old 11-23-2012, 12:54 PM   #12
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Original Poster
Rep: Reputation: Disabled
@ mandyapenguin


Thanks. Yes . I red that one but i got some confusions .. Thanks a lot.
 
  


Reply


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
Use AD to assign a user to a group? Beandip408 Linux - Security 3 08-16-2011 09:38 PM
lp permission assign to user group syedali Linux - Desktop 0 08-06-2011 03:17 AM
add an existing user to an existing group? tramni1980 Slackware 5 05-08-2008 07:28 PM
Adding new group to existing user ALF Linux - Software 7 05-08-2006 09:35 PM
how to add an existing user to a new group? xpucto Linux - Newbie 8 04-19-2006 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:46 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
Open Source Consulting | Domain Registration