Search code examples
linuxpermissionsls

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.


Solution

  • 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