The Linux on how to create a new user, and let it change the password on the fir

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The Linux on how to create a new user, and let it change the password on the first landing, and limit the use of disk space allowed

Free play, the wrong please correct, thanks!


The main steps: setting up user accounts mandatory user account expired limit its disk size
First, create a user.:

1 use useradd to add users

2 using the passwd to set the user password

3 using usermod -L to lock password

4 mandatory user account expired chage -d 0 username

5 to unlock the user account

The above process example:

   # useradd stick
   # passwd stick
   Changing password for user stick.
   New password:
   Retype new password:
   passwd: all authentication tokens updated successfully.
   # usermod -L stick
   # chage -d 0 stick
   # usermod -U stick

Of course the user Dan for the first time login, will prompt you to set the password as follows:

   $ su stick
   Password:
   You are required to change your password immediately (root enforced)
   Changing password for stick
   (current) UNIX password:
   New password:
   Retype new password:
ps: 1, Userdel delete users, this command has to achieve different functions can be parameters. 
    2, The use of useradd useradd -c wangwei -d /opt/stick -G linux,soft_2 -s /bin/bash stick   Note: add stick, real name is Wangwei, the home directory is set in the /opt/stick, Linux, a member of the soft_2 users group, SHELL is bash.

Two, set the disk quota: 
   The user disk space limit is in the file system (District) as the unit, which directory regardless of user files in the file system. 
     1 modified /etc/fstab file. Adding amount of Mount command line option in the file system in the corresponding (the example below). 
  /dev/sda4   /opt  ext3   defaults,usrquota,grpquota   0 0
  2 reload Linux partition, for example: 
  [root@fileserver root]# mount -o remount /opt

  3 in the mounting points to file system and disk quota setting up aquota.user and aquota.group file directory:
  [root@fileserver root]# cd /opt (/Opt as the loading point a single partition /dev/sda4)
  [root@fileserver opt]# Touch aquota.user (set the disk quota for users)
  [root@fileserver opt]# Touch aquota.group (set the disk quota for the user group)
  The formation of aquota.user and aquota.group is empty, do not meet the system requirements. 
  Please go to the next step. 
  4 generation accord with aquota.user and aquota.group system requirements
  [root@fileserver opt]# quotacheck /Opt (generated to meet the system requirements for aquota.user)
  [root@fileserver opt]# quotacheck -g /Opt (generated to meet the system requirements for aquota.group)
  Generation, have error. It's no big deal. Because the previously generated touch is an empty file,  type not sure;. 
  So the correct aquota.user and aquota.group generation. 
  Continue to the next step: 
  5 set the disk into user space limit:
  [root@fileserver opt]# edquota [-u] user_name
  [root@fileserver opt]# Edquota -g group_name (for user group)
  This command to open a VI window, set the disk space and I the number of nodes for the user limit. The soft limit for a temporary quota; hard limit for a permanent limit (soft limit can be slightly larger than the hard limit), and VI editing in exactly the same way, with the ZZ or WQ command: quit. If you want to give some users of user1, user2, user3, specified in the same disk quota, can use the following command to these users are endowed with protuser the same limit:
Below are the parameters I set to create user stick (figure is small, as it is only as a verification, can reach the limits to the unit in like KB)
	1 Disk quotas for user stick (uid 501):
	2   Filesystem                   blocks       soft       hard     inodes     soft     hard
	3   /dev/sda4                       108        100        110         26        0        0
  [root@fileserver opt]# edquota [-u] -p protuser user1 user2 user3
  [root@fileserver opt]# edquota -g -p protgroup group1 group2 group3
  Between soft quota and hard quota to set the time:
  [root@fileserver opt]# edquota -t
  The emergence of a VI window: 
  Grace period before enforcing soft limits for users:
  Time units may be: days, hours, minutes, or seconds
  Filesystem Block grace period Inode grace period
  /dev/sda4 7days 7days
  Modified to your needs, and save the exit is set this time. 
The basic completion of the above, I think the problem should be a lot of, welcome on the back to make improvements. 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Lance at December 24, 2013 - 2:14 AM