1

I have tried for like a quarter an hour to find a way to write a command to automatically convert an existing user into an administrator of a group, but I have not found it, so I did editing with vi /etc/gshadow adding into the group "pupils" into the third row "test"; so then account third should be pupil's admin.

How can I do that trough a command?

How can I verify user test is pupil's admin?

I want to create 40 users as: user01...user40 which are memebers of group myusers and they have the policy: password caducity one month, minimum time to change it, 15 days, warning one week before caducity and one week of inactivity. Also I need a poweruser account which is the admin of that group and this account doesn't have password policy. Every users needs his own directory in /Users, like /Users/user01. Also all users will share a folder called /Users/myusers where they all can write and read. And poweruser won't have his own user directory.

My approach:

#!/bin/bash

#Administrator
adduser -d "" poweruser
#Group where users will be into
groupadd myusers
#A shared directory
mkdir "/Users/myusers/"
#Owned by myusers
chgrp "Users/myusers/" myusers
#They can read and write
chmod 760 "/Users/myusers/"

#Create 40 users: user01...user40
I=1
while [ I -le 40 ]
do
    adduser -g myusers -d "/Users/user"$I user$I
    chage -M 30 -m 15 -W 7 -I 7 user$I
    I=(($I+1))
done

My doubts:

How can I automatize "poweruser" to become "myusers"' administrator? How can I keep the format: user01, user02 with variable I if it will increment like 1,2,3,4, not 01,02..39,40; I mean I can keep it 01,02,03...040 but I need to keep it 1,2...,39,40. How can I make the folder /Users/myusers shareable giving writting and reading privileges to the group "myusers" which involves those 40 users, without letting them to delete it, or delete those files into it? I mean it is not explicity posted on the excercise but I think it should be like this.

Thank you.

  • Try man usermod. If you have issues after that, update your question. – Tigger Nov 1 '16 at 8:59
  • At least on Debian systems, it would be the gpasswd command I think gpasswd -A, --administrators user,... Set the list of administrative users. – steeldriver Nov 1 '16 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.