Linux shell commands which will be used: groupadd, useradd, usermod, gpasswd, id, mkdir, ll, chgrp, chmod, su, cd, touch.
// Note: '#' is used as command prompt.
1) use perl as script to handle the new users adding.
#!/usr/bin/perl
$user=$ARGV[0];
$passwd=$ARGV[1];
if (!$user || !$passwd)
{
print "Note: user name and passwd cannot be NULL.\n";
exit 0;
}
@saltchars = (a..z, A..Z, 0..9); # as a whole for assignment
srand(time || $$);
$salt = $saltchars[rand($#saltchars)].$saltchars[rand($#saltchars)]; # $# is the last index of array
$encrypt_passwd = crypt($passwd, $salt);
$add_exec = "/usr/sbin/useradd -p ".$encrypt_passwd." ".$user;
print $add_exec."\n ";
system($add_exec);
#This perl script runs well in perl v5.10.1 built for i386-linux-thread-multi using root permission.
#saved this file as user_add.pl and
#chmod u+x user_add.pl
#./user_add.pl Tom 123456
#./user_add.pl Lily 123456
2) groupadd project; gpasswd -a Tom project; gpasswd -a Lily project; id Tom; id Lily;
3) mkdir /home/workspace; chgrp project /home/workspace; chmod 2770 /home/workspace;
#Now, directory '/home/workspace' can be shared by Tom and Lily for working or studying together.
#su, cd, touch, ll and other shell commands can be used to do a testing.