Showing posts with label add. Show all posts
Showing posts with label add. Show all posts

Wednesday, May 7, 2014

Linux - Add User to a Group

1. To add existing user to existing group:

$ usermod -G groupname username

or 

$ usermod -g GID username

2. To add existing user to existing supplementary groups

$ usermod -a -G groupname username

-a is switch for append

3. To add user to group when adding user

$ adduser --ingroup groupname username

4. To check which groups user is member of

$ groups username

Thursday, May 1, 2014

Linux - Add User Account

To add user to Linux from command line (shell) type command adduser followed with options and username. Example to add user linips (type sudo if you are not root):

$ sudo adduser linips
Adding user `linips' ...
Adding new group `linips' (1001) ...
Adding new user `linips' (1001) with group `linips' ...
Creating home directory `/home/linips' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for linips
Enter the new value, or press ENTER for the default
        Full Name []: Linips Blog
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]

Defaults are in file /etc/adduser.conf

What if we are want to add user with username format as firstname.secondname?

$ sudo adduser linips.blog
adduser: Please enter a username matching the regular expression configured
via the NAME_REGEX[_SYSTEM] configuration variable.  Use the `--force-badname'
option to relax this check or reconfigure NAME_REGEX.

Then we must add --force-badname switch to command

$ sudo adduser --force-badname linips.blog

and continue with entering data for new user.


Tuesday, April 29, 2014

Linux Add Group

To add group linips to Linux type:

$ groupadd linips

General format of command groupadd is:

groupadd [options] groupname

options are:

  • --help 
  • -g, --GID gid -to assign Group ID
  • -f, --force - -f with -g acts like -g not exist - GID another unique
  • -K, --key KEY=VALUE
  • -o, --non-unique - to add group with non unique GID
  • -p, --password PASSWORD
  • -r, --system - To create system group