Linux Forums - Linux Help,Advice & support community:LinuxSolved.com
Linux in General => Linux Development & Programming => Topic started by: ziox on January 07, 2005, 01:28:18 AM
-
#!/bin/bash
#creating a group then assigning all users to it ....
/usr/sbin/groupadd $1
/bin/mkdir -m 3770 /home/$1 ;
#/bin/chmod 3770 /home/$1 ;
/bin/chgrp $1 /home/$1
for uzr in `/bin/grep /home /etc/passwd | /bin/cut -f 1 -d :`
do
/usr/sbin/usermod -G $1 $uzr
/bin/mkdir -p -m 3770 /home/$1/$uzr"_dir"
done
____________________________________________
with this script i want to create a group then a 'DIR' for
it under /home then assign all users under /home to it
then create "username_dir" for each user within
/home/$group_dir with permission 3770
____________________________________________
$$The problem is when applying this permission
with
chmod 3770 /home/(group-dir) it also
change /home permissions to 3770
even with #mkdir -m
____________________________________________
$$ another question ...
what if not all users $HOME under /home...?
should i play with "UID" ??
____________________________________________
$$ and what about after adding a 'group-of-users' to
a specific Group they automatically been removed from
any another Group
I want them share many groups
____________________________________________
Thanks
-
Let met test the script. It's a full script right?
-
Let met test the script. It's a full script right?
yes it is ...
just u do so
# scriptname group_name_u_want
I use RedHat~9
-
==================
Instead of writing:
==================
#/bin/chmod 3770 /home/$1 ;
/bin/chgrp $1 /home/$1
==================
You can do the following:
==================
cd /home
#/bin/chmod 3770 $1 ;
/bin/chgrp $1 $1
-
the command groups's output for a specific user
consists of :[IN RedHat]
the primary group for the user then any other groups he is member of
So the idea is to take the field/s after the primary group
then add it/them comma separated with the new group we want to add a user in
then the command would be something like that
### groups $uzr
output would be
$user : user group1 group2 [and so on]
Or
$user : user group1
then we've to do
### usermod -G <newgroup,group1,group2> <$user>
--But the problem taking this/those field/s
<the output from the groups command>
then add them comma separated to usermod command like that
groups $uzr | cut -f4,5,6 -d \ ;
usermod -G $1,$x,$z $uzr
where is $1 is the group name u added
$x,$z ...suppose to be the groups which the user
is already member of
How to add them (old_groups) comma separated with -G
_______________________________________________
--this script is very useful in a large network cause it would be silly to add
--all users manually
-
Huh? I dont quite understand ur last sentences. I cant quite catch with ur problem?
It is very interesting indeed. I did that when i was deploying a software in my users' respective account for LTSP environment.
-
Huh? I dont quite understand ur last sentences. I cant quite catch with ur problem?
It is very interesting indeed. I did that when i was deploying a software in my users' respective account for LTSP environment.
when u add a user to a group he automaticlly be removed from any group else
but if we do
usermod -G <newgrp,oldgrp,oldgrp,...,...> <user> then he'll not be removed
thats recomended if the user should be member of more than group
right???
then the problem is inserting his old groups comma separated
and the way i found that taking his old groups from the command
groups's output but this output i couldn't edit it .....
the command is
groups $user
the output
$user : primarygroup additionalgroup and_so_on
Got it :?:
thanks :)