LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   is this useradd statements correct? (https://www.linuxquestions.org/questions/linux-general-1/is-this-useradd-statements-correct-200520/)

namgor 07-02-2004 09:56 PM

is this useradd statements correct?
 
i m still kind of new to linux, i have done man useradd and man groupadd, stil unsure, pls check this for me:

objective:
- add group a, b,
- add user u1 into both group, and root into group b

is the following stmts correct?

groupadd a
groupadd b
useradd -g a u1
useradd -g b -M u1
useradd -g b -M root

thank you.

comp12345 07-03-2004 12:13 AM

For the secondary group use -G. The -g sets the primary group, so the fourth command resets the primary group of u1 from a to b (i.e. u1 belongs to group b, not a and b). You could combine lines 3 and 4 into one line:
Code:

useradd -g a -G b -M u1
Also, the root account is a default account so it will already exist. The command
Code:

useradd -g b -M root
will give you an error. Use usermod to change the profile of an existing account. Your command becomes
Code:

usermod -g b root
Note: The effects do not show until you relogin.

Berhanie 07-03-2004 12:18 AM

the groupadd commands are correct, but don't use useradd to modify existing accounts. instead, use usermod. so the command would be, for example,
Code:

usermod -G a,b u1


All times are GMT -5. The time now is 03:20 PM.