Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am very new to Ubuntu and I still don't understand a lot of basic concepts so please 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 folder 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 writeable? Please help me.

share|improve this question

migrated from Aug 1 '11 at 8:30

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

marked as duplicate by Eliah Kagan, guntbert, Tim, mikewhatever, Eric Carvalho Aug 16 '14 at 0:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 5 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. – Nitin Venkatesh 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 :) – Nitin Venkatesh 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

You do not want to change ownership of /opt or even /opt/lampp. These directories are owned by root for a reason: security . If you go down the path of changing ownership of directories away from root, you are making your system less safe and may open yourself up to serious problems.

The best way to do what you're trying to do is to use a solution similar to what someone here already suggested: use the gksudo command. However, because it's tedious to constantly open a terminal to type the full command, create a shell (.sh) file instead.

1) Open a text editor (something like gedit, leafpad, kate, etc.) and type in the following:

gksudo nautilus /opt/lampp/htdocs

2) Save the file on your Desktop as

3) Open the terminal and type the following (this will change directories to the Desktop, where the above file,, is saved.):

cd Desktop

4) The type in the following (this will make your .sh file executable):

chmod +x

5) Close your terminal and then look for your file,, on your desktop. Double click on it. A window will pop-up asking for your password. When you type it in the xampp htdocs folder will open along with root privileges.

Additional note! Since you are using Xampp on Linux, it might be convienient for you to also repeat the above steps using these codes:

To start Xampp:

gksudo /opt/lampp lampp start

To stop Xampp:

gksudo /opt/lampp lampp stop

To open a text editor (gedit is used here) as root. This will allow you to save to the htdocs folder because opening gedit as root means you can save into the htdocs folder as root.

gksudo gedit

Remember! You will need to make the .sh file executable by running the chmod +x command.

share|improve this answer

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

In the linux terminal navigate to your lampp directory.

cd /opt/lampp

In the command line type:

sudo chmod 777 -R htdocs

The problem should be solved.

Now, I do not like to be the guy who waves the magic wand and says there you go; therefore, I am going to explain what you just did.

You navigated to the directory containing the protected directory. Your problem was that it was a folder that was access protected by your system. When you commanded chmod 777 -R htdocs, what you did was set the permissions for everyone on your computer to read/write/execute - allowed.

What is this 777 ? --> 7: you, 7: us, 7: them.

If you wrote chmod 700 then you (probably root, actually) would have all permissions, and then we (the "user group" in your system) would have no permissions, and everyone else, being the last 0 of the 700 would have none either. To deny everyone permissions it would be chmod 000. Clear? Now, you know what each digit means. It says who the number is about. Now each number from 0-7 sets a permission level. I will simply provide you a link for that.

I hope this helps.

I forgot to add why there is a -R. -R means the command is recursive and will affect htdocs as well as all subdirectories of htdocs and subdirectories of the subdirectories of htdocs.

These numbers do mean something: The first number sets the permissions for the owner, the second sets the permissions for the group, and the last number sets the permissions for anyone else (other). Look at the chart below to see what each number means:

Number Permission(s) Set 0 (zero) No Permissions (the user(s) cannot do anything) 1 Execute Only (the user(s) can only execute the file) 2 Write Only (the user(s) can only write to the file) 3 Write and Execute Permissions 4 Read Only 5 Read and Execute Permissions 6 Read and Write Permissions 7 Read, Write and Execute Permissions

So, placing 7 in all three positions means that everyone in every group can read, write and execute the file. That is how we get the number 777 for this.

As another example, if you use chmod 650, here is the breakdown:

The first number, 6, gives the owner read and write permissions. The second number, 5, gives the group read and execute permissions. The last number, 0, gives all others no permissions for the file.

share|improve this answer
Terribly bad advice - chmod 777 is never needed and could prove catastrophic on a web server. – guntbert Aug 12 '14 at 16:31

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