Permission denied from opening directory

5,953

Main Idea

To stop anyone apart from you having access to a folder, all you have to do is make sure that the last 6 characters in a ls -l are dashes. For example: drwx------

Instructions for terminal

drwx------ will give you full read, write and execute permissions, but only for your user. To set this you have to run chmod 700 folder, where folder is the folder you want to block.

Instructions for GUI

In most file managers, you can right click on the folder, open up the preferences and give the owner read and write permission and set the group and others to no permissions. If your file manager doesn't work like this, post a comment with the name of your file manager so I can add specific instructions for that file manager.

Thanks @ravery for the GUI instructions

NOTE: I will add in pictures when I get a chance

Share:
5,953

Related videos on Youtube

user974407
Author by

user974407

Updated on September 18, 2022

Comments

  • user974407
    user974407 over 1 year

    I have always wondered how you stop another user from entering a directory. I am in a local installation of GitLab and I see that in my git directory I have a repositories directory. If I try to ls or cd into it, it says:

    me@my:/home/git$ ls repositories/
    ls: cannot open directory 'repositories/': Permission denied
    me@my:/home/git$ cd repositories/
    bash: cd: repositories/: Permission denied
    

    If I ls the parent directory I see it doesn't belong to me. But I don't see anything that stops me from going in.

     drwxrws---  3 git  git  4096 Jul  5 00:47 repositories
    

    How is it stopping me from entering or exploring this directory?

    I am not interested in getting into this directory. I am more interested in how they stopped me from getting into it and how I can stop others from getting into directories in the future.

  • user974407
    user974407 almost 7 years
    So using chmod how would you set those on that directory's permissions?
  • Admin
    Admin almost 7 years
    If you use chmod you will be overwriting either the git user or the git group and that will probably stop GitLab from working. Using usermod is the easiest way to do this.
  • Admin
    Admin almost 7 years
    Sorry I was thinking of chown
  • Admin
    Admin almost 7 years
    Although using chmod will get rid of the SUID (s) and that might stuff up GitLab as well
  • user974407
    user974407 almost 7 years
    I updated the question. I am interested in how they blocked me. I don't need access to that repositories directory. I want to know to block others like they blocked me in the future.
  • Admin
    Admin almost 7 years
    I've updated my answer
  • ravery
    ravery almost 7 years
    if you are using a GUI file manager, right click on the file then properties, then permissions. Set group and others to denied; and owner to read write.
  • Admin
    Admin almost 7 years
    @ravery I'll add that in. Do you want me to mention you
  • ravery
    ravery almost 7 years
    if you want, it isn't necessary though