Hello, on your fresh install of XAMPP in Ubuntu and other linux distros, you will face a common problem - you cannot do anything inside htdocs folder. The problem is that since the htdocs folder is present in /opt/ directory it requires password to modify files in the htdocs folder.

1. The easier way

Just enter the following commands in the terminal and you're good to go.
sudo chmod -R 777 /opt/lampp/htdocs
The above command will enable all users in the network to access your htdocs folder. If you don't want this to happen, implement method 2.

2. The harder way

This method will eliminate the problem in the above mentioned method. Do the following.
  1. Find your username by entering the command who am i and you will see the result as shown below.
    who am i command
    who am i command to know your username
  2. Next enter the command in the terminal in the format as follows:
    sudo chown -R username:username /opt/lampp/htdocs
    Replace username with your username and the above code will ask for your password.
    chown command to change ownership of htdocs folder
    chown command to change ownership of htdocs folder
  3. Add the user to the Apache configuration file by the following command
    sudo gedit /opt/lampp/etc/httpd.conf
    The above code will open httpd.conf file in a text editor
  4. editing httpd.conf file to add your username
    editing httpd.conf file to add your username
  5. Find for the following lines
    User nobody
    Group nogroup
    
    Replace nobody with your username, save it and restart XAMPP. That's it.