Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am very new to Ubuntu and I still don't understand alot of basic concepts so pls bear with me.

I successfully installed XAMPP 1.7.4 in my ubuntu 11.04. The XAMPP is installed in /opt/lampp. I know how to write php file in /opt/lampp/htdocs using the bash terminal command sudo gedit /opt/lampp/htdocs/myphpfile.php but what if I already have an existing php file inside a folder? Of course I don't want to write it again using sudo command. All I want to do is copy that foler that contains the php files inside htdocs like I always do in Windows WAMP. Is there a command in which I could set the /opt folder to writable? Please help me.

share|improve this question
possible duplicate of How to avoid using sudo when working in /var/www? – Lekensteyn Aug 1 '11 at 19:14

migrated from stackoverflow.com Aug 1 '11 at 8:30

5 Answers

up vote 1 down vote accepted

You could always open up the file-browser (nautilus) as Arvind said by gksudo nautilus /opt/lampp/htdocs

To expand on Will's answer (you can chmod)

This will change the ownership of the /opt/lampp/htdocs/ to you:

sudo chown username:groupname /opt/lampp/htdocs
Example : (My username is nits and my group name is also nits)
sudo chown nits:nits /opt/lampp htdocs

This will change the folder's permissions to be read, write and executed by you ONLY:

sudo chmod 700 /opt/lampp/htdocs
share|improve this answer
I run sudo chmod 700 /opt/lampp/htdocs code in my Terminal, and i cannot even see the contents in htdocs directory... and how do i change it normal or read/write mode – Rafee Jan 9 '12 at 12:05
Changing the permissions to 700 means give only the owner of the directory read, write and execute permissions. Make sure that you are the owner of the directory with chown. – nitstorm Jan 9 '12 at 16:20
What does 700 and 777 mean? – Santosh Kumar May 17 '12 at 2:44
@Santosh I have explained in the previous comment what 700 is, to know more about file permissions, take a look at the blogpost I wrote a few months back - Understanding File Permissions. I've explained in detail there with self-made diagrams for easy understanding. It'll hopefully clear all your doubts :) – nitstorm May 21 '12 at 15:44

You can also use open nautilus (file browser) as root and type

gksudo nautilus /opt/lampp/htdocs

This will open your file explorer. You can then go to the folder you want to copy the php files from and paste it into the htdocs folder.

Hope this helps! :)

share|improve this answer
previously i directories in lampp were normal, and when I run the above code, all directories become in locked symbol folder.... and how can i make it permantely read/write mode.. rather using above code each and every time when i want to create a php file... – Rafee Jan 9 '12 at 12:03

Linux has tighter permission system, /opt folder is really an admin only area, and that's why it asked you password all the time. where windows just "assume" you are admin

To copy paste without sudo, you will need to use the chmod to change the permission.

I would recommend you type man chmod to read the manual there. try avoid 777.

Beside You better make regular backup as there is no "re-cycle bin" in Linux. if you somehow overwrite a critical file with empty one, it's most likely gone forever.

share|improve this answer
Thanks so much for the advice... – Moron Aug 1 '11 at 7:33

I was having this problem myself, and then I realized I can do just one thing and everything will be flowers and roses every time from now on.

I opened nautilus. Then browsed to /opt/lampp/htdocs.

Then I changed the owner and group to myself, and then I provided the read and write privileges to everyone. However when I tried to do it for the files somehow it was returning back to - instead of Read and write however. This worked. And now I can modify the files stored in htdocs.

share|improve this answer

I used this:

sudo chown username:groupname /opt/lampp/htdocs
sudo chown username:groupname /opt/lampp/htdocs/*
sudo chown username:groupname /opt/lampp/htdocs/*/*
sudo chown username:groupname /opt/lampp/htdocs/*/*/*
...

But owner of every new created file/folder will be root.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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