How to copy files in to var.

5 posts
by trevorboultwood » Sun Nov 04, 2012 6:14 pm
So I just created a website server on the pi following the guide in the raspberry pi user guide. Worked fine first time but I want to put the site i made in to the folder /var/www/... The only thing is, when I drag the files across I dont have permission. How do I copy a file from 1 place to another...... i know sudo but then what? Can I just disable this and make myself a root user? Its ridiculously frustrating...... Thank you.
Trevor Boultwood
Posts: 5
Joined: Sun May 27, 2012 7:00 pm
by pluggy » Sun Nov 04, 2012 6:51 pm
Code: Select all
sudo bash
passwd root

Set the root password to what you want.

Then you can login as root.

Don't use it with a gui and particularly surfing......
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......
User avatar
Posts: 3636
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
by SN » Sun Nov 04, 2012 9:37 pm
issue a sudo su - command whilst logged in as pi
and then you just run as root from there on in
after that cp and cp -r are your friends
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1012
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by penguintutor » Mon Nov 05, 2012 2:43 pm
Rather than logging in to root - if you really want a proper root session then I suggest you instead run an interactive sudo session

Code: Select all
sudo -s

This won't help with your drag-and-drop problem though. You would instead need to run the file manager as root

Code: Select all
gksudo pcmanfm

Even if you try to "ignore" the security features of Linux they are likely to cause problems in future when you wonder why your webserver application can't read the directory that only root can access etc. - so far better to learn it properly.

To set the permissions correctly you should use chown and chmod to set the permissions.

For example if you'd like pi to own the /var/www directory then you would use:

Code: Select all
sudo chown pi /var/www

To make sure everyone can read the directory

Code: Select all
chmod ugo+rx /var/www

u = user (owner of the file / directory)
g = group
o = others (all other users)
r = read access
w = write access
x = execute permission (on a directory allows you to change to that directory)

So that everyone can write to the directory (not required normally, but helps remove the security barrier)
Code: Select all
chmod ugo+rwx /var/www

To take access away use - instead of +

You can also change the permissions of files and sub-directories using File manager - right click on a file or directory - choose properties and then the permissions tab. If you need to change permissions to files or directories that you don't own then that has to be done using root - either on the command line using sudo or through file manager started with gksudo.

I have created a tutorial on Linux file permissions.
User avatar
Posts: 356
Joined: Tue May 08, 2012 9:11 am
Location: UK
by Trigo » Sat Sep 17, 2016 11:12 pm
I'm having similar issue, but i'm not able to pass the credentials phase (DatabaseName, User, etc...)! I've insert them correctly but i'm still getting the message "Sorry, but I can’t write the wp-config.php file"! Should i change the permissions to the directory? if so how?
Posts: 82
Joined: Fri Jun 17, 2016 7:52 pm