Permission Denied in a Folder for a User After Chown and Chmod

permission denied in a folder for a user after chown and chmod

Can dbadmin traverse /home/ec2-user? Try doing chmod a+x /home/ec2-user

There could be more reasons for being denied, like a specific acl or a LSM but this is the most likely cause.

UNIX permissions on directories

The UNIX permissions rwx¹ work on directories as follows:

  • r: You can view the contents of the directory (the names of the files or folders inside)
  • w: You can create new files, delete or rename existing files.
  • x: You can traverse the folder.

The traverse permission means that you can access the folder children (assuming you know its name -which you can obtain if you also have read permission-).

In this case dbadmin could read and traverse / as well as /home, but /home/ec2-user probably had a mode like drwx------ 2 ec2-user in order to protect its contents. Thus, even if you had an important file readable by anyone deep inside your home folder, other users can't get into it, since they wouldn't be able to go pass /home/ec2-user (which is exactly what you wanted to do, in this case).

¹ Note that I am skipping over the more exotic ones.

ls: cannot open directory '.': Permission denied

This error makes sense if you don't have enough privileges to read that directory. try changing the permissions for current user or change the access mode to global i.e 777
For example:

sudo bash
chmod 775 .

OSError - Errno 13 Permission denied

You need to change the directory permission so that web server process can change the directory.

  • To change ownership of the directory, use chown:

    chown -R user-id:group-id /path/to/the/directory
  • To see which user own the web server process (change httpd accordingly):

    ps aux | grep httpd | grep -v grep

    OR

    ps -efl | grep httpd | grep -v grep

Eaccess file permisson denied still showing after using sudo chown

OK it's the file mode, which is:

----rw-rw-
^^^^^^^^^
uuugggooo

Where u = user, g = group and o = other.

Which means user (you) has no access.

Fix with:

sudo chmod 0644 /Users/UI-Developer/.config/configstore/insight-yo.yml

Linux user permissions folder for multiple users

You can use the following function to check the access to all path elements.

pathex ()
{
local p
local a
if [ -x "$1" ]
then
a=access
else
a='NO ACCESS'
fi
printf "%s: \t%s\n" "$a" "$1"
p="$(dirname "$1")"
if [ "$p" != "$1" ]
then
pathex "$p"
fi
}

Esample usage:

$ pathex /var/log/syslog
NO ACCESS: /var/log/syslog
access: /var/log
access: /var
access: /

chmod: cannot read directory `.': Permission denied

Directories need the execute permission set in order to see their contents.

From http://content.hccfl.edu/pollock/AUnix1/FilePermissions.htm

You can think of read and execute on directories this way: directories are data files that hold two pieces of information for each file within, the file's name and it's inode number. Read permission is needed to access the names of files in a directory. Execute (a.k.a. search) permission is needed to access the inodes of files in a directory, if you already know the file's name.

When you change a directory permission to 644, you are unable to read the files in that directory although you can read that directory to see it exists.

You need to do this:

$ chmod -R 0755 .

A better way might be to use string permission if you simply want to turn off

Otherwise, you can see the directory, but not access the information in that directory.

You maybe better off using relative permissions instead of absolute permissions:

$ chmod -R go-w .

Will remove write permission from group and other, but not touch execute permission.

You can also use find just to set the directories or just to set files:

$ find . -type d -exec chmod 755 {} \;

This will only touch directories, setting read and execute permission on all directories and setting write permission for the owner. This way, you're not setting execute permission on files themselves.

How do I change directory permissions for laravel logs?

Solution, courtesy of a kind soul named Rashedul.

The reason the above solutions didn't work was that previously the owner was nobody. Changing the owner to root allowed the change to take effect

sudo chgrp -R $USER Storage_path

How to move a file out of /usr/local if I get Permission Denied?

Try this:

Check whether you have write access to the folder with

ls -l

Then you can try changing the ownership of the folder to your current user.

sudo chown -R your_username /path/to/folder

See this.

permission denied creating directories as non-root in docker

That happens because your /test directory was created by root, and by default won't allow any other users to create anything in it. To change ownership to the user you want, you can use chown before your USER testuser step:

RUN chown testuser /test

If there are already files inside the directory, you will need to pass the -R flag to change the permission recursively:

RUN chown -R testuser /test

Another option would be giving the directory red+write+execute permissions for all users. However, this is probably NOT what you want, the above should serve you well for almost all cases.

RUN chmod 777 /test


Related Topics



Leave a reply



Submit