LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Explain Linux folder permission (https://www.linuxquestions.org/questions/linux-newbie-8/explain-linux-folder-permission-764403/)

AGazzaz 10-25-2009 05:53 PM

Explain Linux folder permission
 
Hello,
I have been using linux for years now but I have never thought about this until now

What if I want to deny a specific user from accessing a specific folder, how can this be done?

This command is after a quick search
Quote:

Set the permissions for the user and the group to read and execute only (no write permission) on mydir.

$ chmod ug=rx mydir
$ ls -ld mydir
dr-xr-x--- 2 unixguy uguys 96 Dec 8 12:53 mydir

where did this command specify the user or the group?
and as a modern linux user how can this be done through the GUI? (you may not answer that)

In the permissions tab in any file properties under "Advanced permissions" you will find three check boxes "Set UID", "Set GID" and "Sticky" what are these?

Thank you.

chrism01 10-25-2009 06:33 PM

Last qns sound like homework, so I'll just say: http://linux.die.net/man/1/chmod

pixellany 10-25-2009 08:31 PM

Hmmmm---starts like a real question and ends sounding like homework.....

I'm not up on the "sticky" part, so I'll stick to basics....pun unintentional....;)

For any file or directory, you have 3 entities: the owner, the group, and everyone else. To control access to ONE item, simply assign it to a unique group, and then manage who gets assigned to that group....

To the best of my knowledge, there is no simple way to deny just one user---you have to just make sure that he or she is the only one not assigned to the unique group.

rich_c 10-25-2009 09:49 PM

There was a very good article abouot just this in the most recent Linux Format #125.

lwasserm 10-25-2009 10:05 PM

Quote:

Originally Posted by pixellany (Post 3732375)
.....

...there is no simple way to deny just one user---you have to just make sure that he or she is the only one not assigned to the unique group.

Actually IIRC, there is a fairly simple approach that goes something like this:

Code:

$ chown other-user:excluded-user file
$ chmod 707 file


jschiwal 10-25-2009 10:39 PM

Also look at the manpage for setfacl. I will sometimes have to resort to the manpage to remember the exact syntax, so I'm not really RTFM'ing you. The manpage has examples, which are clearer then using the --help option.

If there is already a group assigned, and you need more granular control, setfacl can help. Especially in a case such as when the group has read-only access but you want a particular user to have read-write control.

Of course, you should create your own users and learn by experimentation, using chmod, chgrp and setfacl on a directory and gain first hand experience using permissions.

AGazzaz 10-26-2009 05:14 AM

Thank you all,

First, I have finished my education for a very long time so this is not a homework.
Second, I am Microsoft Certified and administering a windows 2003 server and of course a windows network. Linux OS is on my personal laptop only so there is no one using it but me. I have never thought about securing a folder in linux until I read this article yesterday about windows 7 security.

In windows you can explicitly deny a user from accessing a folder in a couple of simple steps but it seems to be more than that in Linux. and your replies just made me think I have to go out to the very beginning to understand how to do such a simple task. for example in all those years I have not heard/used chown, setfacl, getfacle, acl or umask. Only chmod 777 and sometimes done with kdesudo dolphin so I do not have to open a konsole

I do not know where to start but I need a source that will sum all things up not a man page explaining a single command or a command for a single task. if you know such source please let me know

Thank you.

merchtemeagle 10-26-2009 08:41 AM

Linux Files and File Permission

thorkelljarl 10-26-2009 09:31 AM

There is also, for example...

http://tldp.org/HOWTO/DOS-Win-to-Linux-HOWTO-4.html

If that HOWTO wasn't helpful, there are many others; tldp has collected many sources of information in one place.

http://tldp.org/

pixellany 10-26-2009 09:43 AM

Quote:

Originally Posted by lwasserm (Post 3732411)
Actually IIRC, there is a fairly simple approach that goes something like this:

Code:

$ chown other-user:excluded-user file
$ chmod 707 file


Does not that syntax change the owner and the group attributes for the file? i.e. you would still have to assign your restricted user to the "excluded-user" group.

chrism01 10-26-2009 06:47 PM

Fundamentally, Linux perms are built around the concept of restricting positive access, not specifying negative access.
IOW, get the correct ownerships (user:group) and give the minimum reqd access perms (of rwx) to each of ugo (user,group,other).
For finer tuning, you may add acls.

AGazzaz 10-26-2009 06:53 PM

Quote:

Originally Posted by chrism01 (Post 3733454)
Fundamentally, Linux perms are built around the concept of restricting positive access, not specifying negative access.
IOW, get the correct ownerships (user:group) and give the minimum reqd access perms (of rwx) to each of ugo (user,group,other).
For finer tuning, you may add acls.

I think you mean that the computer is restricted to the root account only and whoever I want to access a folder I give them a permission for that specific folder, other than that the user is already restricted

Am I correct?

chrism01 10-26-2009 07:02 PM

Not exactly. That link in post #8 is good. Have a read first, then come back with any qns.
Just point out that for a file rwx = read,write,execute; for a dir its read,write,x=search(!).
See also http://en.wikipedia.org/wiki/File_system_permissions

lwasserm 10-27-2009 03:51 PM

Quote:

Originally Posted by pixellany (Post 3732902)
Does not that syntax change the owner and the group attributes for the file? i.e. you would still have to assign your restricted user to the "excluded-user" group.

On the systems I am familiar with every user has a default group that is the same as their username. What I meant was, assign ownership of the file to some arbitrary user, and assign the group to that default self-named group of the user to be excluded, not to some larger group that includes the user. While I think that approach would work, after thinking about it some more, I believe my memory may have been in error. See what you think about this example:

The username to be excluded is "excluded-guy"
The file is named FILE
We want everyone else to be able to read or write to the file.
Then root could do:

# chown excluded-guy:root FILE
chmod 077 FILE

If FILE was in a directory owned by root, then anyone except excluded-guy could read or write, but not delete FILE, and excluded-guy could do neither, but would be able to see it in a directory listing. Imagine the frustration of being the owner of a file, yet you can't read, write, or delete it!

chrism01 10-27-2009 05:48 PM

Give it a try on a test file/dir. I suspect that the owner could (should be able to) change the perms.


All times are GMT -5. The time now is 07:47 AM.