Syntax: useradd username
Example: useradd redhat
In above example, we are creating a user called redhat. This command will create a user home directory under /home/ path with redhat user/group permission as shown below.
Set User Password
Syntax: passwd username
Example: passwd redhat
passwd command is used to set or change the password for existing linux user account.
2. Delete UserSyntax: userdel username
Example: userdel redhat
This command will delete only a redhat user account not a home directory data.
Delete User with Home Directory
Syntax: userdel -r username
Example: userdel -r redhat
This command will delete a redhat user account and its home directory(/home/redhat/).
If you didn't use -r then delete a user home directory manually using rm -rf command mentioned below:
rm -rf /home/redhat/
The above command will delete your entire home directory and we cannot restore it back. So before executing rm -rf command make sure you have taken a backup of required files.
3. Enable User QuotaTo enable a user quota, follow the below steps:
Step:1 Edit fstab file using vim editor. Add usrquota & grpquota on /home mount point line after the defaults with seperated by comma.
[root@worldwidelinux ]# vim /etc/fstab
Save and Close the file by pressing Esc key and type :wq! then press Enter key.
Step:2 Reboot your server to reflect the user quota allocation on /home mount point.
Step:3 Turn on quota for home file system
[root@worldwidelinux ]# quotaon -avug
Verify quota is turned on or not using below command:
[root@worldwidelinux ]# repquota -a
soft: Once soft limits reached, it will warn a users(Size should be in KB).
hard: Once hard limits reached, it will not allow users to create files(Size should be in KB).
4. Set User QuotaSyntax: edquota -u username
For example, set a redhat user quota soft as 786 MB and hard as 1024 MB.
[root@worldwidelinux ]# edquota -u redhat
Change value of soft limit value as 804864 and hard limit value as 1048576 in KB.
Save and Close the file by pressing Esc key and type :wq! then press Enter key.
Verify quota is allocated to user or not using below command:
Execute below command, to set a same existing user quota to new user, execute below command:
Syntax: edquota -p olduser newuser
For example, copy user redhat quota to redhat1 user.
[root@worldwidelinux ]# edquota -p redhat redhat1