4

I'm looking for example additional configuration done on new user creation, the kind of stuff that goes beyond /etc/skel. For example, has anyone written a script to set public_html set-GUID?

2 Answers 2

3

Here's a trivial script I wrote to change permissions, because adduser discards permissions when copying from /etc/skel.

#!/bin/sh
# This script is executed at the end of adduser
# USAGE:
# adduser.local USER UID GID HOME

chgrp www-data $4/public_html    
chmod g+s $4/public_html
0

Here is an example I use to create a matching MySQL User for the Unix user.

Switch to root:

user@ubuntu:~$:sudo su

Create useradd script:

root@ubuntu:~#nano /usr/local/sbin/adduser.local

Paste the following:

#!/bin/sh
# This script is executed at the end of adduser
# USAGE:
# adduser.local USER UID GID HOME

mysql -vv -e "CREATE USER '$1'@'localhost' IDENTIFIED WITH auth_socket;"

Control+o to save then Control+x to quit.

Then the crucial part is making the script executable:

root@ubuntu:~#chmod u+x /usr/local/sbin/adduser.local

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .