March 28, 2024, 09:25:16 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: assigning permissions  (Read 6509 times)

Offline ziox

  • Linux Noob !
  • *
  • Posts: 12
    • http://groups.yahoo.com/group/linuxCity/
assigning permissions
« 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

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
assigning permissions
« Reply #1 on: January 08, 2005, 01:34:04 PM »
Let met test the script. It's a full script right?

Offline ziox

  • Linux Noob !
  • *
  • Posts: 12
    • http://groups.yahoo.com/group/linuxCity/
assigning permissions
« Reply #2 on: January 08, 2005, 02:48:23 PM »
Quote from: "dragoncity99"
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

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
assigning permissions
« Reply #3 on: January 10, 2005, 12:41:18 AM »
==================
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

Offline ziox

  • Linux Noob !
  • *
  • Posts: 12
    • http://groups.yahoo.com/group/linuxCity/
assigning permissions
« Reply #4 on: January 10, 2005, 03:10:21 PM »
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

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
assigning permissions
« Reply #5 on: January 10, 2005, 03:20:41 PM »
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.

Offline ziox

  • Linux Noob !
  • *
  • Posts: 12
    • http://groups.yahoo.com/group/linuxCity/
assigning permissions
« Reply #6 on: January 11, 2005, 12:11:54 AM »
Quote from: "dragoncity99"
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 :)