Permission Denied when trying to read file w/644 permission - linux

I am trying to write a PHP script for a Web server (lighttpd) to read a file in another user.
The Web server runs under user http:
http 1929 336 0 Nov20 /usr/bin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
The file the script is trying to read has the following permissions:
-rw-r--r-- 1 pi www-data 721 Oct 30 05:20 /home/pi/bmSunday
Which I thought meant that any user can read it.
The fopen in the script results in a Permission denied:
Warning: fopen(/home/pi/bmSunday): failed to open stream: Permission denied in /srv/http/p1/index.php
I am running Arch Linux.
uname -r
displays:
4.4.32-2-ARCH
What permissions do I need to set on the file so that user http is allowed to read it?
By the way, am I correct in assuming I can also test the permission via:
sudo -u http cat /home/pi/bmSunday
Using the above command, the result is:
cat: /home/pi/bmSunday: Permission denied

The permissions on the directory are probably wrong, http probably doesn't have execute permission. Add world execute permissions:
chmod o+x /home/pi

You (as a user) in your example have no execute permissions. So yes chmod +x file. Keep in mind this adds execute to both users others.

If you give all other user execute permission on home directory of other users it compromise security to all other user. it will be better if you give permission only http user by acl.
$ setfacl -m u:http:r-x /home/pi

Related

Django, I am getting "Permission Denied" when trying to access a directory that is given to an ftp user

My django application (v1.8) is using a directory for exporting some csv files. This directory is something like: "/home/username/django_project/csv_out".
I have intentionally chmod the "csv_out" dir to 777.
My partner wanted to access this directory in order to download and inspect those csv files.
I created an FTP user like this:
useradd ftp_user -p somepassword -d /home/username/django_project/csv_out/ -s /bin/false
Since then I get a "Permission Denied" error from Django (was not getting that error before): The FTP Server is giving access to the folder without problem. Django "misbehaves".
IOError: [Errno 13] Permission denied: '/home/username/django_project/csv_out/weights_1.csv'
Am I doing something wrong?
PS: I am using proftpd ftp server
You also need +x (search) permission on /home/username and /home/username/django_project/ directories for ftp_user
Try this
chmod a+x /home/username
chmod a+x /home/username/django_project/
note your ftp user is different from your website user.
which user account you started your django website?

Bash permission denied in cygwin

I have a directory:
drw-rwxrw-+ 1 username Domain Users 0 Feb 11 09:32 webapp
But when I try to enter this one I get
-bash: cd: /cygdrive/c/dp-project/.../web-app Permission denied
What's wrong? I setted all permissions to all users.
No you didn't "setted all permissions to all users". Execution permission is only set for group. try to chmod a+x webapp.
One othe thing first line webapp second line web-app that is not the same.
The plus (+) sign a the end of the permissions indicates that the file or directory has access control lists set. use:
getfacl /path/to/dir
to read all those acls. Most probably your user or groups access is prevented.

mkdir: cannot create directory `pgsql': Permission denied

I want to create directory like below:
ajs#ajs-HP-Compaq-dc5800-Small-Form-Factor:/usr/local$ mkdir pgsql
mkdir: cannot create directory `pgsql': Permission denied
But I am getting error:
Permission denied
How can I resolve and create directory pgsql in this location /usr/local$
Kindly suggest me, hope for reply.
Thanks
You have to check your user name to have permission for creating directory in the folder /usr/local$
Check your permission for the folder by the command
ls -ltr /usr
Link to refer about file permissions.
You are getting a Permission denied error because you do not have access rights to create a directory in /usr/local. You can determine the access rights for these directories by using the stat command. The output will look something like this.
$> stat -c '%n %A %G %U' /usr /usr/local
/usr drwxr-xr-x root root
/usr/local drwxr-xr-x root root
Now double check who you are. You can use the whoami command or the id command invoked below twice to reveal both username and group.
$> id -un; id -gn
In the stat output, root:root owns both /usr and /usr/local and only the owner may create (write) new directories based on the access rights. In order to create the directories, I'd recommend either becoming root or trying the command with sudo. If this is not possible, I'm afraid you'll have to create the directory elsewhere or contact the administrator of that machine.
You probably have to be root to do such things in /usr/local.

Permission denied for root shrc

Whenever I open the terminal on my Centos5.1, I always get this error
/root/.cshrc Permission denied
and then I can't use networking commands (ip,ifconfig,...) because they are reported as unknown commands.
Verify that you have permissions to read .cshrc To do that issue:
ls -l /root/.cshrc
If the output begins with to dashes it means that you don't. To give yourself read permission to this file issue:
chmod +r /root/.cshrc
Now if you run ls -l /root/.cshrc the output should start with -r.

ant Permission Denied problem

After extracting and saving the ant files into an opt/ directory and setting the path variable
to $ANT_HOME/bin
I ran the following command on a CentOS 5
ant -version
and I am getting the following error
-bash:/path/opt/apache-ant-1.8.2/bin/ant: Permission denied
Is there some permission I am supposed to set or some typical source of this problem?
Thanks!
If you own the file, try
chmod u+x /path/opt/apache-ant-1.8.2/bin/ant
If someone else owns it, either sudo or become root then
chmod 755 /path/opt/apache-ant-1.8.2/bin/ant
You need to have execute permissions on the file; the first gives execute permissions to the owner only and is probably preferable if you own the file and are the only one that uses it. The second requires root privileges and gives execute and read permission to everyone, plus write permission to the owner.
You can view the current permissions and ownership of the file by running ls -l /path/opt/apache-ant-1.8.2/bin/ant.

Resources