4

How can I set up my Solaris system so that every time a user is created and assigned to a specific group, a specific file is placed in that user's home directory?

blahdiblah
  • 115
  • 2
Nestor
  • 41
  • 1
  • 6
    Any file in `/etc/skel` will be copied to a user's directory when the account is created. I know of no way to make this action dependent on membership of a specific group, though. – roaima Aug 18 '22 at 08:16
  • 2
    This seems a [XY problem](https://xyproblem.info/). What is it that you _actually_ want to obtain? This can probably be solved with a global script that checks group membership, or similar. – Ángel Aug 18 '22 at 23:20

1 Answers1

5

You can do this by creating specific script to add new users. As Solaris offer a lot of options to useradd I will provide just example:

#!/bin/bash
# use format <script> <username> <group>
if [ "$2" = "predefined_group" ]
then useradd -k /new/path/for/skel -g "$2" "$1"
else useradd -g "$2" "$1"
fi

and do not forget to create new directory with skeleton files and the file you want to copy.

Romeo Ninov
  • 16,541
  • 5
  • 32
  • 44