LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [Q] Permission free directory? how? (https://www.linuxquestions.org/questions/linux-newbie-8/%5Bq%5D-permission-free-directory-how-4175440510/)

iKosmos 12-07-2012 07:11 PM

[Q] Permission free directory? how?
 
I have looked around and played with chown, chmod, & setfacl to not avail.

Currently I use an ntfs drive as a shared drive with my family. Every one can read, write, axecutr, and delete anything on it. But I really want to do that now on a linux drive as well.

I want all users to have all permissions to do everything. With setfacl I got everything except delete a few times but nothing was permanant.

Help please!

teckk 12-07-2012 07:41 PM

http://ss64.com/bash/chmod.html

shivaa 12-07-2012 08:24 PM

All this can be done using a few commands:
1. Give yourself (let your username is user1) ownership of the shared directory:
Code:

chown user1 /path/to/dir
2. Create a new group named family and add all users to that group.
Code:

groupadd family
usermod -a -G family user1 user2 user3...

3. Change permission mode of shared drive:
Code:

chmod 755 /path/to/dir
So you've excluded write permission for family group, so none other than you can delete content of shared dir. On the other hand you will have full permissions.

iKosmos 12-07-2012 08:31 PM

non protected directories
 
Will these permissions be inheritable on subdirectories?

Something like a windows samba share with "allow users to change files" checked.

shivaa 12-07-2012 11:29 PM

In that case, invoke chown and chmod recursively by just adding -R option, as:
Code:

chown -R user1 /path/to/dir
chmod -R 755 /path/to/dir

It will apply same on all subdirectories and files.

iKosmos 12-09-2012 07:39 AM

Quote:

Originally Posted by shivaa (Post 4844970)
In that case, invoke chown and chmod recursively by just adding -R option, as:
Code:

chown -R user1 /path/to/dir
chmod -R 755 /path/to/dir

It will apply same on all subdirectories and files.

Including NEW files/folders created afterwards?

shivaa 12-09-2012 08:21 AM

Quote:

Originally Posted by iKosmos (Post 4845640)
Including NEW files/folders created afterwards?

No! It will not be applied on newly created file/dir. But to achive this, let's go little deeper :)
Any newly creaeted file/dir gets it permission assigned on basis of umask value defined in your .profile file. If umask entry is commented in .profile (i.e a # written against it) file, then it considers umask values defined under /etc/profile.
So to check it, invoke:
Code:

grep "umask" ~/.profile
If it gives some output (Note: umask is generally set to 022), and if umask is already set to 022, then open the .profile file for editing, remove "#" written against umask entry and also change it's value to 022 if needed. Then any newly created file will get 755 permission by default, which means no write permission to group or others.

Second (perhaps I forgot to mention in previous post), add SGID on shared drive directory, so any newly created file/dir inside it will get same group as that of parant dir. has, using:
Code:

chmod -R g+xs /path/to/dir
---- To summerize all posts, you've to do following -----
1. Change permissions of already existing files/dir/subdirectories to 755:
Code:

chmod -R 755 /path/to/dir
2. Add yourself as owner of all files/dir/subdirectories:
Code:

chown -R username /path/to/dir
3. Set SGID on all dir/subdirectories:
Code:

chmod -R g+xs /path/to/dir
4. Change umask value to 022 (if not already set to 022) and uncomment umask entry from .profile.

And you're done! Test it once and let's know if still you've any problem.

TobiSGD 12-09-2012 08:30 AM

Quote:

Originally Posted by iKosmos (Post 4844892)
I have looked around and played with chown, chmod, & setfacl to not avail.

Currently I use an ntfs drive as a shared drive with my family. Every one can read, write, axecutr, and delete anything on it. But I really want to do that now on a linux drive as well.

I want all users to have all permissions to do everything. With setfacl I got everything except delete a few times but nothing was permanant.

Help please!

Before giving any recommendations about file-permissions the real question is: How does your family connect to the shared drive, is it an USB device, a network share, ...?
Most likely this is not a file-permissions thing, but a "How do I setup the sharing service correctly?" problem.

iKosmos 12-10-2012 07:31 AM

File Permission on Shared directories
 
First, thank you everyone.

Second, It is a shared external drive. We have a shared NAS but for larger files we use an external USB hard drive. Normally I have the formatted as NTFS and so anyone can read, write, execute, etc... But I would like to have a partition formatted as ext4 and also I have run into this before where I write a file to an ext3/4 partition and now my kids can not access it.

Also, on a shared laptop I want a data partition that no matter who logs in to the machine, they can read/write/execute anything on the data drive. Again, currently I solve this by leaving the data drive as ntfs but sometimes I WANT permissions on certain directories and none on others. This can only be done in linux if I can be able top create real shared directories that anyone can do anything in this directories without resorting to ntfs partitions.

TobiSGD 12-10-2012 07:45 AM

Are all your machines Linux machines? Windows machines will not be able to read ext4 formatted drives.

iKosmos 12-11-2012 03:55 PM

Yes all running pclos 2012

TobiSGD 12-11-2012 04:46 PM

In that case the disk should do what you want by default, except that a user can't delete or write to the files a different user has created. Unless all users have the same UID or are member of a group that is present with the same GID on all systems and the group has rwx rights on the files/directories.
I don't know how PCLOS handles the default groups of users, but usually they all should have the same GID on all machines.

Example: On a Debian system the first created user will have the UID 1000, regardless of its username (and if not specified differently by the admin). So if you have two Debian machines the first user on any of those machines can access the files of the first user on the other system, because both have the same UID.

This works similar with groups, of course only if the group has the rights to access the files.

So if all your family members have their own machines with only their user account on it (besides root) it should work out of the box.


All times are GMT -5. The time now is 03:56 AM.