2020年8月7日 星期五

how to add a user with quota limit on ubuntu?

於Ubuntu作業系統想手動新增用戶,可利用如下adduser指令。

#################################
# add user with a login name of user_name
###################
$sudo adduser  --home=/home/user_name  user_name
正在新增使用者 `user_name' ...
增加新群組 `user_name' (10xx) ....
正在新增新使用者 `user_name' (UID 10xx) 到群組 `user_name' ....
正在新增家目錄 `/home/user_name' ...
正在從 `/etc/skel'複製檔案 ...
輸入新的 UNIX 密碼:
再次輸入新的 UNIX 密碼:
passwd: 密碼已成功地變更
正在改變 user_name 的使用者訊息
請輸入新值,或直接按 ENTER 鍵以使用預設值
	全名 []: user full name
	房間號碼 []:
	工作電話 []: phone
	住家電話 []:
	其它 []:
以上輸入的資料正確嗎? [Y/n] Y


#################################
# confirm user profile of user_name
##################
$ grep user_name /etc/passwd
user_name:x:10xx:10xx:user full name,,phone,:/home/user_name:/bin/bash


#################################
# assume quota limit of source_user is 
#        Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
#      /dev/sdyy      zz         30000000 100000000              13       0       0
# copy disk quota limit settings of source_user to user_name
##################
$sudo edquota -p  source_user   user_name


################################
# confirm disk quota limit
#   blocks: usage of data blocks
#   quota:  soft limit of data blocks
#   limit:  hard limit of data blocks
#   grace:  grace period when soft limit of data blocks is exceeded
#   --
#   files:  usage of inode blocks
#   quota:  soft limit of inode blocks
#   limit:  hard limit of inode blocks
#   grace:  grace period when soft limit of inode blocks is exceeded
#   --
#   when grace period is exceeded, no further writing to disk is allowed 
#     until usage is reduced below soft limit
##################
$sudo quota -u user_name
Disk quotas for user user_name (uid 10xx):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/sdyy      60  30000000 100000000              13       0       0