How do I set the permission, so I can? The "Create new folder" option is greyed out. I tried this: sudo chmod -rw /opt/lampp/htdocs
But it still doesn't work. When I add sudo chmod -rw 755 /opt/lampp/htdocs, it says: "755" no such file or directory
You are mistaking how chmod and the unix file permissions operate.
You need to configure the /opt/lampp/htdocs directory so that the user you are logged in as has permission to write. You also need to ensure that what you write in there can be read by whatever web server LAMPP uses (I'm not familiar with LAMP unfortunately.)
First you need to look at who is owning /opt/lampp/htdocs:
Should return something like:
The first bit (dwrxr-xr-x) is the file permissions. "lampp" is the owner of the directory, and "www" is the group-owner of the directory. You need to note this one.
First off let's sort the group. If the group is anything except "root" then all is well and good and you can skip this section:
If it's "root" it will need changing to something more sensible. Let's make a new group for it to belong to:
Then change the group on the directory:
Now you need to make the web server run as the group www. If the web server is Apache then you should check the /etc/apache/httpd.conf file and edit the "Group" setting accordingly. I don't know the setting for other web servers.
Now this is where you'd skip to if you didn't need to switch the group from root to something else.
We now need to address the permissions on the directory. We want to be using some very special permissions, called the "setgid" bit.
You see the permissions have now changed somewhat. Let's explain these.
The "s" in the group permissions is called the "setgid" bit. This is a special permission which causes any files created in the directory to inherit the group-owner from the directory itself. So if user "fred" in group "users" makes a file in there it would be owned by "fred" in group "www". This is very useful for a shared area where multiple people all read and write the same files.
But as it stands you still don't have the ability to write to that area. Why? Because you're not in the "www" group. Let's rectify that now:
Replace "www" with the group-owner of the /opt/lampp/htdocs directory you noted near the beginning.
You will need to log out and in again for this change to take effect - your group memberships are read at login time.
Once you have done that you should suddenly find you can now magically write files in /opt/lampp/htdocs.
If you have other users on the system that you want to allow to write to there, just add them to the www group with the
you use EITHER +rw OR the octals, not both.
What you're trying to do is remove read and write privileges from a directory called 755 as well as /opt/lampp/htdocs.
In any case, you shouldn't be using xampp - you can get a more up to date, native install of a lamp stack - you can install it with tasksel.