June 20, 2011

centos add user group

Adding a group in CentOS:
groupadd %groupname%

Creating a new user and adding him to a group:
useradd %username% -g %groupname%

Just adding a new user:
useradd %username%

Attaching an existing user to a group:
usermod -g %groupname% %username%

Check:
id %username%

Note! You may be getting errors like
bash: useradd: command not found
bash: groupadd: command not found

In this case, as advised here, use full path to commands or if you're using su, type it as follows:
su -

No comments: