File:  [NetBSD Developer Wiki] / wikisrc / tutorials / user_management.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Mon Nov 21 03:22:58 2011 UTC (6 years, 7 months ago) by mspo
Branches: MAIN
CVS tags: HEAD
finish importing the pages from my findings in the wiki


[[!toc levels=2]]


Before you start to do user and group management you must: 

1. For security reasons, create substitute user and name it as you like, here it is referred as _noroot_: 
    # useradd -m -G wheel _noroot_

2. Set password for _noroot_ user: 
    # passwd _noroot_

3. Exit and log in as _noroot_ user. 

4. Use the **su** command to obtain the root privileges for _noroot_: 
    $ su

5. Forget to use the **root** for maintenance or regular administration of the system. You free to find any secure and convenient spot for the root password be available upon your need. 

If your favorite user with login password is already assigned in the system and no need to create new one. Omit first steps from above. Do modify user information by adding _your no root user_ into the wheel group and **su** anytime per your desire: 
    # usermod -G wheel _noroot_


The NetBSD maintains information in regard of each user who logs into, access system, runs processes on so forth. This include and not limited to: 
    - user name
    - password
    - group
    - base_dir
    - skel_dir
    - shell
    - class
    - homeperm
    - inactive
    - expire

The superuser called root has no limitations on its privileges. 

To limit user priveleges consider to set limits by: coredumpsize, cputime, filesize, quota, maxproc, memory, openfiles etc. 

**user** is frontend to the useradd, usermod, userinfo and userdel commands, it helps to manage users in the system. 

Use [id]( to see user identity: 

**$ id**

Use [w]( to see who present and what they are doing: 

**$ w**

Use [last]( to see last logins: 

**$ last**

##  [[basics/useradd]]

To add user do: 
    **user add** [options] _user_

To add a user and create a new home directory: 
    **# useradd -m** _myuser_

Look into the NetBSD Guide [Chapter 5.6](

##  [userinfo](

To see user information do: 
    **$ userinfo** _myuser_

##  [[basics/usermod]]

To modify existing user login do: 
    **# user mod** [options] _user_
    **# usermod -C yes** _username_             ; set Close lock on user account
    **# usermod -C no** _username_              ; unlock user account
    **# usermod -G wheel** _username_           ; add user to group _wheel_
    **# usermod -s /sbin/nologin** _username_   ; remove login shell
    **# usermod -s /bin/sh** _username_         ; set login shell
    **# usermod -F** _username_                 ; force user to change password

##  [userdel](

To remove a user from the system do: 
    **# userdel** _myuser_

##  [[basics/passwd]]

To see a list of all users in the system do: 
    $ cat /etc/passwd

To edit _/etc/passwd_ file do: 
    # vipw

##  [[basics/chpass]]

Use [chpass, chfn, chsh](( to add or change user database information. 

To change the shell of _myuser_, for an exapmle to /bin/ksh: 
    **# chpass -s /bin/ksh** _myuser_


#  [**Group**](

To manage groups check **/etc/group** file which maintains name of each group, group id and list of users who is a group member. 

**group** is frontend to the groupadd, groupmod, groupinfo and groupdel commands, it helps to manage groups in the system. 

To add group do: 
    **group add** [options] _group_

To delete group do: 
    **group del** [options] _group_

To obtain group information do: 
    **group info** [options] _group_

To modify existing group do: 
    **group mod** [options] _group_

To remove user from the group you have to do **user del** and then add user again. 

##  [groupadd](

##  [groupdel](

##  [groupinfo](

##  [groupmod](

#  Other

##  [[basics/chmod]]

##  [[basics/chown]]

To change files/directory ownership: 
    #chown -R  myuser path 

Where myuser is the name of user and path is directory where files are located. 

##  [[basics/chgrp]]

##  [[basics/chroot]]

##  [[basics/quota]]

Use quota to set users quotas per desire. 

#  See also

  * [[How to set up per-user timezones]]
  * How to [[Hide other user's processes]]
  * [[Userland version]]
  * [[The_NetBSD_System_Manager's_Manual#Users_and_Accounts_Management]]

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb