linux mv command not working on server, works on local machine

I have a linux command that I need to execute like this mv "/var/www/html/website/files/1.pdf" "/var/www/html/website/files/complete/2015.pdf" the command works flawlessly on my local machine, and it should on my server too because the directories are there. I think the problem is maybe I have bad apache or user config on the server, idk? can someone try to steer me in the right path?

to clarify: the problem is: i am getting a directory or file not found error on the server but not on the local machine. both have the exact same directories.(pulled in from a git repo)


Solution 1:

When the command works on one machine and not on the other obviously they are different and not identical. It helps when you include the complete error message.

What error message mv "/var/www/html/website/files/1.pdf" "/var/www/html/website/files/complete/2015.pdf" generates depends on what is wrong. The "No such file or directory" error you indicate occurs when one or both of the source and destination paths are incorrect, but there is a subtle difference in error messages:

mv: cannot stat '/var/www/html/website/files/1.pdf': No such file or directory

occurs when that original file does not exist, but also when the directory path /var/www/html/website/files/ does not exist. Since the source doesn't exist the mv command stops processing right away. If the destination path is also incorrect you won't see an error regarding that now.

mv: cannot move '/var/www/html/website/files/1.pdf' to '/var/www/html/website/files/complete/2015.pdf': No such file or directory

the error is still "No such file or directory" but the source path is quoted and therefore correct and the error lies in the destination.

If the problem lies in your permissions, mv will tell you that differently:

mv: cannot stat '/var/www/html/website/files/1.pdf': Permission denied