Access the Web Directory in Ubuntu 16.04

Estimated Completion Time: 10 Minutes | Difficulty: Beginner


Knowing how to access your web root on your Ubuntu server is critical in order to upload your documents to the web. In this tutorial, we will create a new user account to handle the file transfers, give the user account administrative access, and utilize FileZilla to connect to our FTP server. This tutorial is written as a sequel to my original article Create a Web Server with Digital Ocean that I had written last week, but it can be followed from without having to read the original article.

Create a User Account

If you followed my previous tutorial, Create a Web Server with Digital Ocean, then skip to the Give User Ownership of Web Directory portion of the guide.

Let start with creating a new user account for ourselves and give it permission to run administrative tasks. The root username is the default administrator account, but it is best practice to not use the root account unless completely necessary. The root user is the administrative user in a Linux environment that has very broad privileges. Because of the heightened privileges of the root account, you are actually discouraged from using it on a regular basis1.

  • In the console run the command below as root with ### being the name of the account you would like. For example, adduser ryan. You will have to enter and confirm a password for this user. Write this information down.
adduser ###
  • After creating a password you will be prompted with a few questions for this username (your full name, phone numbers, room number, etc.) these values are not critical to the account. Fill them out if you wish or hit the Enter key to skip the question. Once the questionnaire is completed you will be prompted to confirm the data. If all is correct enter ‘Y’ and hit the Enter key. We have successfully created a primary user account.

Give the User Account Administrative Privileges

Now that we have an additional user we need to give it administrative permissions to complete the tasks going forward.  This will allow our normal user to run commands with administrative privileges by putting the word sudo before each command1.

  • In the console window enter the command where ### is the username you have chosen earlier. For example, usermod -aG sudo ryan is what I would use.
usermod -aG sudo ###

Give User Ownership of Web Directory

  • Run the command below, where ###  is the username you’ve created, to give our user account ownership of the web directory. You will need to enter your password.
sudo chown -R ### /var/www

Configuring FileZilla

  • If you have not already, download and install FileZilla here. Follow the installation wizard.
  • The easiest way to add your server to FileZilla is to import an XML file. Copy the XML code below into a text editor and save the file as FileZilla.xml. Replace IP ADDRESS HERE with your server’s IP address and replace USERNAME HERE with the user account created in previous steps. Since this is a plaintext file we will want to encrypt our password before we import it into FileZilla.
<?xml version="1.0" encoding="UTF-8"?>
<FileZilla3 version="3.29.0" platform="windows">
      <Host>IP ADDRESS HERE</Host>
      <User>USERNAME HERE</User>
      <Pass encoding="base64">ENCRYPTED PASSWORD</Pass>
      <Comments />
      <LocalDir />
      <RemoteDir />
  • To encrypt our password we will go to a web service that encodes text for security purposes, Base64Encode. Navigate to the website and enter your password in the first text area. Click the ‘>ENCODE<‘ button and copy the encrypted password from the text area below.

  • Paste the encrypted password into the FileZilla.xml file where the ENCRYPTED PASSWORD placeholder is. Save the file.
  • Launch FileZilla. If there is a splash screen/advertisement just close the window. In FileZilla, go to File -> Import.

  • Select the FileZilla.xml file we created and import. This will import out server’s connection properties into FileZilla and we are ready to go.

  • Connect to the server by clicking the drop-down menu in your Site Manager and selecting the Ubuntu16.04Server option.

  • You should now be connected to your Ubuntu server via FTP.

  • In the ‘Remote site:’ text box enter /var/www/html and hit Enter. This is the web directory for your server.

  • Let’s test the server by uploading a .html file in this path. Open a text editor, copy the below code, and save the file as index.html.
<!doctype html>
<html lang="en">

  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>Test Website</title>


<h1>Hello, thank you for following my tutorial. I am glad to see it is working for you!</h1>


  • We will upload this index.html file using FileZilla to our server by navigating to the file’s location on the left pane, right-clicking the file and selecting the Upload option.

  • You can now see your index.html file on the server in the right pane.

  • If we navigate to our web server on an internet browser, by going to the address http://### where ### is the IP address of your server. You should now see text from the page below.


You now have access to your web directory where you are able to host your own website and files. There is more to learn, but for now, we have a solid foundation for web development and other projects. Happy building!

1Sourced from DigitalOcean

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.