Linux command
setquota 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Set quota for a user
sudo setquota -u [username] [block-soft] [block-hard] [inode-soft] [inode-hard] [/path/to/filesystem]
Set quota for a group
sudo setquota -g [groupname] [block-soft] [block-hard] [inode-soft] [inode-hard] [/path/to/filesystem]
Copy quota settings
sudo setquota -u -p [prototype_user] [target_user] [/path/to/filesystem]
Set quota on all filesystems
sudo setquota -a -u [username] [block-soft] [block-hard] [inode-soft] [inode-hard]
Set grace times
sudo setquota -t -u [block-grace] [inode-grace] [/path/to/filesystem]
Set quotas from batch input
echo "[username] [block-soft] [block-hard] [inode-soft] [inode-hard]" | sudo setquota -b [/path/to/filesystem]
说明
setquota is a command-line quota editor that sets disk quotas for users, groups, or projects on a filesystem. Unlike the interactive edquota command, setquota allows quota configuration in a single command, making it suitable for scripts and automation. Quotas can limit both disk space usage (blocks) and number of files (inodes). Each limit has a soft limit (can be exceeded temporarily) and a hard limit (absolute maximum). When a soft limit is exceeded, the grace period begins, after which the soft limit becomes a hard limit. Block limits are typically specified in kilobytes, though this may vary by quota format. If a numeric value is given instead of a username, it is treated as a UID/GID/project ID.
参数
- -u, --user
- Set user quotas for the named user. This is the default.
- -g, --group
- Set group quotas for the named group.
- -P, --project
- Set project quotas for the named project.
- -p, --prototype _protoname_
- Copy quota settings from a prototype user, group, or project.
- -b, --batch
- Read quota information from standard input. Format: name block-softlimit block-hardlimit inode-softlimit inode-hardlimit.
- -t, --edit-period
- Set grace times (in seconds) for users, groups, or projects.
- -T, --edit-times
- Alter time remaining for individual users when soft limit is enforced.
- -a, --all
- Apply to all filesystems with quotas listed in /etc/mtab.
- -F, --format _quotaformat_
- Specify quota format: vfsold, vfsv0, vfsv1, rpc, or xfs.
- -r, --remote
- Edit remote quota using rpc.rquotad.
FAQ
What is the setquota command used for?
setquota is a command-line quota editor that sets disk quotas for users, groups, or projects on a filesystem. Unlike the interactive edquota command, setquota allows quota configuration in a single command, making it suitable for scripts and automation. Quotas can limit both disk space usage (blocks) and number of files (inodes). Each limit has a soft limit (can be exceeded temporarily) and a hard limit (absolute maximum). When a soft limit is exceeded, the grace period begins, after which the soft limit becomes a hard limit. Block limits are typically specified in kilobytes, though this may vary by quota format. If a numeric value is given instead of a username, it is treated as a UID/GID/project ID.
How do I run a basic setquota example?
Run `sudo setquota -u [username] [block-soft] [block-hard] [inode-soft] [inode-hard] [/path/to/filesystem]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -u, --user do in setquota?
Set user quotas for the named user. This is the default.