LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-30-2004, 08:34 PM   #1
pembo13
Member
 
Registered: May 2003
Location: Caribbean
Distribution: Fedora Core2
Posts: 403

Rep: Reputation: 30
How to set default file creation


Hello,

I would like to setup a user wich creates files by default with chown=myuser:specialgrp and chmod=775.

Normally it uses it's deault group.

How do i setup all this? To be quite honest i know about umask i just don't know how to set it up.

Thank you.
 
Old 06-30-2004, 09:04 PM   #2
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
umask us used to "switch off" bits on file creation.

e.g. - you don't want any world rights ==> umask 007


i recommend "man creat" as a starter.
 
Old 06-30-2004, 09:19 PM   #3
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480° N, 95.3690° W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
usermod -g groupname
To set the users initial groups which will set the group when he creates files.

Put
umask 002
in their ~/.bash_profile
But, like AltF4 said, I would make the umask 007
 
Old 06-30-2004, 09:54 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Edit the fourth field of the /etc/passwd file. This is the GID entry for the user. Change it to the GID of the new default group. Your can look up the GID number of the group from the /etc/group file.

For example (as root),
1) add a user edward.
useradd edward
passwd edward[enter]
edspassward[/b][enter]

2) add a group edgroup.
groupadd edgroup

3) examine record for user edward
grep edward /etc/passwd
edward:x:502:502::/home/edward:/bin/bash

4) examine record for group edgroup
grep edgroup /etc/group
edgroup:x:503

5) edit gid field for user edward in /etc/passwd. (i.e. change second 502 to 503)
sed '/^edward:/s/:502:502:/:502:503:/' /etc/passwd >/etc/passwd.tmp
mv -f /etc/passwd.tmp /etc/passwd

You could use an editor like vi to edit the /etc/passwd file if you prefer.

Now log in as user 'edward' and touch a testfile.
touch testfile
ls -l testfile

Notice that the group field of the listing says edgroup.

---

ps
The solution given above is better. While I was testing my answer on another computer he submitted his answer. (how do I delete a message I wrote? I tried 'Reset Message' but it didn't work)

Last edited by jschiwal; 06-30-2004 at 10:05 PM.
 
Old 07-01-2004, 10:39 AM   #5
pembo13
Member
 
Registered: May 2003
Location: Caribbean
Distribution: Fedora Core2
Posts: 403

Original Poster
Rep: Reputation: 30
Thanks alot guys. I was hoping there was a way to maintain a different default group in /etc/passwd from the default group used for wrinting fines. Guess that that s not possible.

Thank you.

Last edited by pembo13; 07-02-2004 at 10:43 PM.
 
Old 07-02-2004, 10:21 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You'll need to repeat the last response. I didn't understand what you mean by 'wringing'.

You can create a new group and make certain users members of that group. You can also make this group their default group with the 'usermod -g groupname' mentioned above. That should provide exactly what you were asking about in your original message.

However, what is usually done is leaving the default group alone, but making users members of a certain group. This is the linux version of ACL lists.
 
Old 07-02-2004, 10:44 PM   #7
pembo13
Member
 
Registered: May 2003
Location: Caribbean
Distribution: Fedora Core2
Posts: 403

Original Poster
Rep: Reputation: 30
Quote:
Thanks alot guys. I was hoping there was a way to maintain a different default group in /etc/passwd from the default group used for wrinting fines. Guess that that s not possible.

Thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
locale: Cannot Set LC_ALL to default locale: No such file or directory. asym Linux - General 11 10-24-2018 05:54 PM
default group on file creation antony.booth Linux - Security 3 08-24-2007 06:36 AM
RPM Spec file creation: %file section question davidas Linux - Newbie 0 03-16-2004 10:36 PM
Where to set default file permissions (umask)? tredegar Linux - Newbie 14 01-27-2004 05:10 PM
How to set file creation time in Linux Ian Knight Programming 1 05-06-2003 05:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration