On Linux, how does one create a new user, change the password after the first login, and limit the disk space it allows?

Source: Internet
Author: User
In Linux, how do I create a new user, change the password after the first login, and limit the free disk space allowed by the user? correct the error. thanks! Main steps: Create a user account to force the user account to expire to limit the disk size I. First, create a user on Linux and change the password after the first login, and restrict the disk space it allows for idle time. if any error occurs, correct it. thanks!
Main steps: Create a user account to force the user account to expire to limit the disk size 1. create a user first:

1. use useradd to add a user

2. use passwd to set the user password

3. use usermod-L to lock the password

4. force the user account to expire chage-d 0 username

5. unlock a user account

Example of the above process:

   # 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 first time you log on to dan, you will be prompted 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. delete a user using userdel. this command has parameters to implement different functions.
2. useradd usage useradd-c wangwei-d/opt/stick-G linux, soft_2-s/bin/bash stick note: add the user stick. the real name is wangwei, the home directory is set in/opt/stick. it is a member of linux, soft_2 user group, and SHELL is bash.
 
II. set the disk quota:
The user's disk space is limited by the file system (partition), regardless of the directory in which the user's file is stored.
1. modify the/etc/fstab file. add the limit option to the mount command line of the file system (example below ). /Dev/sda4/opt ext3 defaults, usrquota, maid 0 0 2. reload Linux partitions, for example, [root @ fileserver root] # mount-o remount/opt 3. create an aquota in the installation directory of the file system to which the disk quota is to be added. user and aquota. group File: [root @ fileserver root] # cd/opt (/opt is the loading point of a single partition/dev/sda4) [root @ fileserver opt] # touch aquota. user (set the disk quota for the user) [root @ fileserver opt] # touch aquota. the created aquota. user and aquota. the group is empty and does not meet the requirements of the system. Please refer to the next step. 4. generate aquota that meets system requirements. user and aquota. group [root @ fileserver opt] # quotacheck/opt (generate aquota compliant with system requirements. user) [root @ fileserver opt] # quotacheck-g/opt (generate aquota compliant with system requirements. group. This does not matter. Because touch previously generated an empty file, the format must be incorrect. In this case, aquota. user and aquota. group are generated correctly. Next step: 5. set the disk space limit for the User: [root @ fileserver opt] # edquota [-u] user_name [root @ fileserver opt] # edquota-g group_name (for user groups) this command opens a vi window and sets the disk space and the number of I nodes for the user. the soft quota is a temporary quota. the hard quota is a permanent quota (the soft quota can be slightly larger than the hard quota). the editing method is the same as that of vi and exit with the ZZ or: wq command. to specify the same disk quota for several users, such as user1, user2, and user3, use the following command to grant these users the same quota as protuser:
Below are the parameters I set for the user stick created above (the number is small, because it is only used for verification, and the unit seems to be KB)
1 Disk quotas for user stick (uid 501 ): 2 Filesystem blocks soft hard inodes soft hard3/dev/sda4 108 100 110 26 0 0 0 [root @ fileserver opt] # edquota [-u]-p protuser user1 user2 user3 [root @ fileserver opt] # edquota-g-p protgroup group1 group2 group3 set the time between soft quota and hard quota: [root @ fileserver opt] # A vi window is displayed in edquota-t: Grace period before enforcing soft limits for users: Time units may be: day S, hours, minutes, or seconds Filesystem Block grace period Inode grace period/dev/sda4 7 days 7 days change to what you need, and save and exit to set this time.
I think there should be many problems above. You are welcome to post it for improvement.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.