LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-21-2007, 07:26 AM   #1
veeramani
Member
 
Registered: Apr 2006
Posts: 33

Rep: Reputation: 15
Question How to setup write permission for a user


hai,

i have a directory "test" , with user and group belongs to root.
drwxr-xr-x 2 root root 1024 Mar 21 17:53 test

i want to set write permission to a particular user(normal) who does not belongs to root group in my system to this folder.

What i need to do???
 
Old 03-21-2007, 08:09 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,950
Blog Entries: 5

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
You could "chmod 777 test" which would make it drwxrwxrwx meaning anyone can write to it. This is BAD security however.

A better idea would be to change the group to something else. If root owns it then it doesn't need to be in the root group for root to access it. By putting it in a different group then adding your non-root user to that group both root and that user could access it but no one else could.

Another way to do it to restrict security would be to do the 777 mentioned above then set ACLs so that only the user would be able to access it.

By the way I hope your "test" is NOT so that you can allow a non-root user to access system directories like /etc, /bin and others. That is an extremely BAD idea. If you trust someone enough to access those then you should give them root access as they can do as much damage with writing files (and removing them) as they can with the password. Also many things won't work if the permissions are not what they are expected to be by security mechanisms - this is done on purpose to prevent hackers from simply going in and changing permissions to 777 on everything.

So the key question here is WHY are you trying to give a non-root user access to a directory owned by root?
 
Old 03-21-2007, 08:10 AM   #3
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
First, get familiar with the format of the files /etc/passwd and /etc/group:

Code:
head /etc/passwd
man 5 passwd
head /etc/group
man 5 group
A user is automatically a member of the group which is specified in his entry in file /etc/passwd. In the following example, user snave is user 3001, in group 3000:

Code:
snave:x:3001:3000:,,,:/u/snave:/bin/bash
But you can add user snave to other groups, too. Suppose you also want him to be a member of group business, which in this example is group 6000. In file /etc/group, you'd start with

Code:
business::6000
and change it to

Code:
business::6000:snave
If you want to have more than one user add this group as a supplementary group, you'd change that line to this instead:

Code:
business::6000:user1,user2,user3
Ok, so in your situation you want to define a new group whose purpose it is to define those who can change the directory in question. (You don't need to worry about root, who can do anything.) Define a new group, picking a group ID which does not yet appear in file /etc/group. Specify the names of users who should be able to modify the directory. In this example, we chose group ID 7654:

Code:
testgroup::7654:user1,user2,user3
Then all you have to do is this:

Code:
chgrp testgroup /wherever/testdirectory
chmod 775 /wherever/testdirectory          # was 755 before
... and you're set.

Hope this helps.

Last edited by wjevans_7d1@yahoo.co; 03-21-2007 at 08:14 AM.
 
Old 03-21-2007, 08:21 AM   #4
veeramani
Member
 
Registered: Apr 2006
Posts: 33

Original Poster
Rep: Reputation: 15
Thank you

Thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Mounted a filesystem as root.How does one give write-permission to a user? Mr.DeVillie Linux - Software 4 02-08-2006 07:20 AM
Shared partition and user write permission dashnaam Linux - General 3 07-10-2005 01:22 PM
No write permission for /home/user/... payasam Mandriva 2 12-24-2004 12:33 PM
Sharing a directory with a regular user (with write permission) Ironica Linux - Newbie 6 05-31-2004 11:27 AM
no write permission? santasballz Linux - Newbie 1 02-12-2004 11:26 PM


All times are GMT -5. The time now is 04:03 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration