This is a discussion on etc/skel - change owner when adduser? within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Hi I have a bunch of default files in my skel directory, problem is, when i adduser the files ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi I have a bunch of default files in my skel directory, problem is, when i adduser the files are just copied keeping the user that created them in the skel dir owner, i need the newly added user to be owner of the files copied to his home dir, I've been trying to add a chown command to the adduser script, but I've never done scripts before so I have no idea where to start or what I'm doing wrong. Any help/ideas? I tried googling for it but came up empty (I have a nasty habbit of always using the wrong words :-() Thanks Morten -- Replace .hej with .com in my e-mail prior to sending e-mail. |
| |||
| In alt.os.linux.slackware, Morten Lundstrøm dared to utter, > I've been trying to add a chown command to the adduser > script, but I've never done scripts before so I have no idea where to start > or what I'm doing wrong. > Any help/ideas? Here's what I would do. (Many lines snipped.) This is on a Slackware 9.0 machine. Your version may be slightly different. # Add the account to the system CMD="$useradd "$HME" -m "$EXP" "$U_ID" "$GID" "$AGID" "$SHL" "$LOGIN"" $CMD if [ $? -gt 0 ]; then echo "- Error running useradd command -- account not created!" echo "(cmd: $CMD)" exit 1 fi # These next few lines are what you need to add. # Copy the contents of /etc/skel to the user's home directory. cp -aR /etc/skel/* "${HME}" # Change the owner and group of those files. chown -R "${U_ID}":"${GID}" "${HME}" # Set the finger information $chfn "$LOGIN" if [ $? -gt 0 ]; then echo "- Warning: an error occurred while setting finger information" fi -- It is better to hear the rebuke of the wise, Than for a man to hear the song of fools. Ecclesiastes 7:5 |
| |||
| > I have a bunch of default files in my skel directory, problem is, when > i adduser the files are just copied keeping the user that created them > in the skel dir owner, i need the newly added user to be owner of the > files copied to his home dir, I've been trying to add a chown command > to the adduser script, but I've never done scripts before so I have no > idea where to start or what I'm doing wrong. > Any help/ideas? The useradd command does this for you. This is the DEFAULT behavoir. moya:/etc/skel# ls moya:/etc/skel# touch mumu moya:/etc/skel# ls -l mumu -rw-r--r-- 1 root root 0 Feb 21 10:36 mumu moya:/etc/skel# useradd -m test moya:/etc/skel# ls -l /home/test/mumu -rw-r--r-- 1 test users 0 Feb 21 10:36 /home/test/mumu Just be sure to use -m or to use adduser script in order the homedir to be created and files copied! -- Claudiu Cismaru |
| |||
| "Claudiu Cismaru" <claudiu@cnixs.com> skrev i en meddelelse news:c175h8$1f298e$1@ID-225382.news.uni-berlin.de... > > I have a bunch of default files in my skel directory, problem is, when > > i adduser the files are just copied keeping the user that created them > > in the skel dir owner, i need the newly added user to be owner of the > > files copied to his home dir, I've been trying to add a chown command > > to the adduser script, but I've never done scripts before so I have no > > idea where to start or what I'm doing wrong. > > Any help/ideas? > > The useradd command does this for you. This is the DEFAULT behavoir. > > moya:/etc/skel# ls > moya:/etc/skel# touch mumu > moya:/etc/skel# ls -l mumu > -rw-r--r-- 1 root root 0 Feb 21 10:36 mumu > moya:/etc/skel# useradd -m test > moya:/etc/skel# ls -l /home/test/mumu > -rw-r--r-- 1 test users 0 Feb 21 10:36 /home/test/mumu Hehe, I must have been sleepy when I did it, I only had 3 users on my system when I changed my skel dir, so I decided just to manually copy the files, next day when I checked the ownership was incorrect... *oops* Sorry for taking your time with a stupid question like that one :-) /Morten |
| ||||
| "Alan Hicks" <1001298936@carrier.lizella.net> skrev i en meddelelse news:slrnc3d81b.au3.1001298936@carrier.lizella.net ... > In alt.os.linux.slackware, Morten Lundstrøm dared to utter, > > I've been trying to add a chown command to the adduser > > script, but I've never done scripts before so I have no idea where to start > > or what I'm doing wrong. > > Any help/ideas? > > Here's what I would do. (Many lines snipped.) This is on a Slackware > 9.0 machine. Your version may be slightly different. > > # Add the account to the system > CMD="$useradd "$HME" -m "$EXP" "$U_ID" "$GID" "$AGID" "$SHL" "$LOGIN"" > $CMD > > if [ $? -gt 0 ]; then > echo "- Error running useradd command -- account not created!" > echo "(cmd: $CMD)" > exit 1 > fi > > # These next few lines are what you need to add. > # Copy the contents of /etc/skel to the user's home directory. > cp -aR /etc/skel/* "${HME}" > > # Change the owner and group of those files. > chown -R "${U_ID}":"${GID}" "${HME}" > > # Set the finger information > $chfn "$LOGIN" > if [ $? -gt 0 ]; then > echo "- Warning: an error occurred while setting finger information" > fi Thanks, I just figured my mistake out myself, Sorry for taking your time :-) /Morten -- Replace .hej with .com in my e-mail prior to sending e-mail. |