Permission denied from opening directory
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
Related videos on Youtube
user974407
Updated on September 18, 2022Comments
-
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 arepositories
directory. If I try tols
orcd
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 almost 7 yearsSo using
chmod
how would you set those on that directory's permissions? -
Admin almost 7 yearsIf you use
chmod
you will be overwriting either thegit
user or thegit
group and that will probably stop GitLab from working. Usingusermod
is the easiest way to do this. -
Admin almost 7 yearsSorry I was thinking of
chown
-
Admin almost 7 yearsAlthough using
chmod
will get rid of the SUID (s
) and that might stuff up GitLab as well -
user974407 almost 7 yearsI 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 almost 7 yearsI've updated my answer
-
ravery almost 7 yearsif 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 almost 7 years@ravery I'll add that in. Do you want me to mention you
-
ravery almost 7 yearsif you want, it isn't necessary though