I'm trying to open a PHP file on my Raspberry Pi running Raspbian. But it won't let me move the file from its current location to the 'www' folder I keep getting an error message saying 'Access Denied', I've looked online and it seems that I need to login with the credentials 'pi' and 'raspberry' however I never logged in before, I was always automatically logged in when I turned the Pi on. Is there any way to get over this issue? I'm sure it's simple but I'm not used to Raspberry Pi's so it's difficult

migrated from stackoverflow.com Mar 16 '17 at 21:02

This question came from our site for professional and enthusiast programmers.


You are logged in automatically as the Pi user with the default password. The reaason you can't copy a file to the /var/www/ directory is because you do not own the folder. To get around this do the following from a termianl window:

switch to the directory where the file you want to move is located (assuming the file is in your home directory):


then move the file with the following command (substituing the file name you want to move):

sudo mv name_of_file_to_move /var/www/

If you want to copy the file instead of moving it use this command instead of the previous one:

sudo cp name_of_file_to_copy /var/www/

When asked for a password use raspberry (assuming you have not changed the password).

you can check the file has been moved to the new location with the following command:

ls -la /var/www/

You could use this command in the terminal to make your user the owner: 'chown user /path/to/your/directory' make sure only folder for now not the file for the file use 'chown user /path/to/your//folders/file/you/need/access/'

above just replace the 'user' with your account thats not the root account the one that you are signed into for file browsing!
and replace the '/path/to/your/directory' and '/path/to/your//folders/file/you/need/access/' to your exact file path Also you can use a /* to gain access to all files and supfoldors in a directory


Use sudo raspi-config to run the initial config again and setup a new root user so you can use it to have the priviliges you need.


  • This is not required. His Pi is setup to autologin as the Pi user. The issue is that the Pi user does not own the www directory, and as a result he needs to use sudo to move the file. – Steve Robillard Mar 16 '17 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.