2017-06-04 67 views
-1

嗨我正在为一个学校作业编写一个shell脚本,但似乎无法根据需要使其工作。贝娄是我迄今为止所拥有的。我想要做的是添加帐户名称,例如用户帐户创建时的真实姓名。此外还有一个Cron选项卡,可在每天11:59记录磁盘使用情况并将其保存到storage.log中。user_create.sh Ubuntu shell脚本

#!/bin/bash 

IFS="," 

while read f1 f2 f3 f4 

do hostname $f1 
    useradd $f2 
    passwd $f3 
    groupadd $f4 

     #echo "Real name  : $f1" 

     #echo "Username   : $f2" 

     #echo "Default password  : $f3" 

     #echo "Group Name  : $f4" 

59 11 * * * sudo du >>/home/bond/Desktop/GroupActivities/storage.log 
done < /home/bond/Desktop/GroupActivities/data.csv 
+0

什么是你的问题? – syntagma

+0

如何分配帐户名称?例如乔恩doe jdoe –

回答

0

useradd命令有一个标志,不正是你所需要的,从man useradd

-c, --comment COMMENT 
     Any text string. It is generally a short description of the login, and is currently used as the field for the user's full name. 
+0

嗨,我不明白这一点,它仍然无法正常工作。你可以编辑我提供的代码 –