简体   繁体   中英

In Linux how do I set permissions for a directory that prevent a user from listing, deleting or creating files within?

I'm doing a homework assignment for a Linux class I'm taking and I need to make it so users other than the owner cannot list, delete, or create any files within a directory. They also must still be allowed to access the files (assuming they know the directory and file name since they aren't allowed to list it), but are not allowed to modify or execute. I already have it so the users cannot modify or execute with the chmod, but I'm not sure how to go about stopping users from listing or deleting files in the directory.

If your username is alex and the folder name is homework,

  1. try
    chmod -R 700 homework

from your login

  1. ensure the owner is alex. Else change ownership using the command

chown alex:alex homework

Now login using another username and execute

ls homework

you should get permission denied error

"Users other than the owner"

So we're talking about the groups and other

"Cannot delete, create [...] modify or execute it"

Remove the wx rights for the others and groups :

chmod -R g-wx o-wx  /path/to/your/file

Quick chmod recap :

  1. u = owner of the file (user)
    g = groups owner (group)
    o = anyone else on the system (other)

  2. add permission (+)
    remove permission (-)

  3. r = read permission
    w = write permission
    x = execute permission

About preventing them from listing a directory , I dont know if it is possible but you can probably find what you're looking for by reading here:
http://www.penguintutor.com/linux/file-permissions-reference
and here : https://askubuntu.com/questions/200911/how-to-prevent-access-to-a-folder-by-other-users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM