problem with viewing zip file on public_html

Asked by jomccaslin

I'm trying to get a large file to a friend of mine. I zipped it and then scp it into my public_html folder and this worked. But then when I send him the URL to download it it says something about unauthorized permission. ssh into my public_html folder and type ls, it shows the .zip file in green. There's another one in there that he can view that shows up in red. . . What's the difference and how I can I make it so that people can download the .zip when I send them the link? Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
jomccaslin
Solved:
Last query:
Last reply:
Revision history for this message
Andy Ruddock (andy-ruddock) said :
#1

For him to be able to download the file it must be readable by the process which will access the file on his behalf.
In this case the process is Apache which usually runs as user www-data and group www-data.

Files in your home directory, and your public_html directory, usually have your user and group permissions, which means that the file must be readable by others for the Apache process to be able to read the file.

If you're using Nautilus to set file permissions you need to set "Others" to have "Read" permission on the relevant file, you also need to set "Others" to have "Execute" permission if they are to be able to move into sub-directories from public_html.

Revision history for this message
jomccaslin (jomccaslin) said :
#2

I've scp-ed a .zip file in there before, and that one is viewable/downloadable or whatever for others when I send them the URL. I don't know what I did differently. Also, whenever I put a .pdf or .txt or any other file extension in there there are no problems-it only seems to be with a .zip file. . . only sometimes. How would I go about making the necessary changes?

Revision history for this message
Andy Ruddock (andy-ruddock) said :
#3

Open terminal window.
Type

ls -l ~/public_html

You should get a file listing which will look like

-rw-r--r-- 1 user group <filesize> <date> <time> filename1
-rw-r----- 1 user group <filesize> <date> <time> filename2

The leftmost characters show the permissions for each file. In the example I've given, the first file is readable and writable by the files owner, which is "user", and readable by the files group "group", and readable by everybody else.
The second file is also readable and writable by the same owner, readable by the files group, but everybody else has nt permissions on the file.
To set the permissions on this file so it becomes readable by everybody, execute the following command :

chmod o+r filename2

So in your case, if the filename is called file.zip you'd enter

chmod o+r ~/public_html/file.zip

(Note, for this to work you have to be the owner of the file)

Revision history for this message
jomccaslin (jomccaslin) said :
#4

So I ssh-ed into my public_html folder and it seemed to work because now I can download it when I paste the URL into the searchbar. Thanks for the help. One thing however: the color is still the same when I hit ls. Should I expect that to change? What is the significance of differing colors?

Revision history for this message
Andy Ruddock (andy-ruddock) said :
#5

The colour is determined by the contents of the LS_COLORS environment variable and changes depending upon what the type of the file is and whether it's executable or not.
See the command "dircolors" for help on setting the LS_COLORS environment variable.

Revision history for this message
jomccaslin (jomccaslin) said :
#6

Ok thanks for the help!