How to Mount a Hard Drive at Boot in Ubuntu 22.04

mount hard drive boot ubuntu 22.04 splash image

Efficiency and convenience are at the heart of any well optimized operating system experience. Imagine every time you start your Ubuntu 22.04 system having all of your hard drives automatically mounted at boot. This is where the power of configuring /etc/fstab comes into play.

In this article we will explore automatic drive mounting in Ubuntu 22.04 using fstab. You’ll gain the skills to ensure your system efficiently recognizes and mounts your hard drives as part of its boot sequence. Whether you’re an experienced Linux user or just getting started, this guide will walk you through the process. This will make your daily computing tasks smoother and more efficient. So let’s dive in and improve your Ubuntu hard drive mounting experience.

List Drives and Partitions

list all partitions and disks

The first step to mounting you hard drive at boot is finding its name. You can list out all hard drive and partition names using the lsblk command. Our drive is the 32GB one labled “vda”. The partition we want to mount is “vda1”. Locate your drive and partition name from the list as it may differ. In most cases it will be sdb or sdc.

lsblk -a

Create Mount Point

create a mount point directory

The next step is creating the folder for the drives mount point. We will be using the media folder but feel free to use the mnt folder instead. Use the following command to create a mount folder called data in the media folder.

sudo mkdir /media/data

Open The fstab File

open /etc/fstab file

After we create the mount directory we will edit the fstab file. Open it using the nano command below.

sudo nano /etc/fstab

Add Mount Point Line

add mount point line

Once the fstab file is open we will navigate to the bottom of the file and add a new line. Replace /dev/MOUNT_POINT with the partition from the disk you want to mount. You will also need to replace /media/MOUNT_DIR with the directory you want to mount it in. After you have added the line save and close the file. In our case we will be using /dev/vda1 and /media/data.

#Hard Drive Mount Points
/dev/MOUNT_POINT /media/MOUNT_DIR ext4 defaults 0 0

Mount All Partitions

mount all drives

After editing the fstab file we need to remount all of the partitions. Use the mount -a command to mount them.

sudo mount -a

Verify Mounting

verify you can see mounted files

Now we want to check if the disks partition was mounted successfully. Use cd to navigate to the mount point you used in the fstab file, and verify that you can see your files. You can use the ls command to list all files. If you can see your files in the mount directory you have successfully configured a partition to mount at boot in Ubuntu 22.04.

cd /media/data && ls

Reboot System

reboot system

After verifying that we can see our files in the mount directory the last step is to reboot the system. Use the reboot command to proceed. Once your system reboots you should see you hard drives partition mounted in the mount directory automatically. This concludes the guide on automatically mounting hard drives at boot.

Fstab FAQ

What is fstab in Linux and what is its purpose?

fstab stands for “file system table” and is a configuration file in Linux that specifies how various storage devices, such as hard drives and partitions should be mounted on the file system at boot. It defines the mounting points, file system types, options, and other parameters essential for device mounting. Essentially fstab ensures that your storage devices are accessible and functional every time your Linux system starts up.

Can I mount network shares and remote filesystems using fstab in Linux?

Yes, you can use fstab to mount network shares and remote filesystems in Linux. To do this you would typically use entries that specify the network location (such as NFS or Samba shares) along with the mount point and other necessary parameters. By configuring fstab in this way you can ensure that these network resources are automatically mounted at boot. This will provide you with seamless access to remote data or networked storage devices. View our tutorial on How to Mount an SMB (Samba) Share in Linux with cifs-utils for additional information.

What should I do if I encounter errors or issues after editing the fstab file?

If you encounter errors or issues after editing the fstab file it’s important to address them promptly to prevent disruptions to your system. Here are some steps to follow:

  • Double-check your fstab entries for accuracy. Ensure that the device paths, mount points, and options are correctly specified.
  • Use a rescue or live Linux environment to access your system if it fails to boot due to fstab errors. From there you can make corrections to the fstab file.
  • If you’re unsure about a specific entry consider commenting it out (adding a “#” at the beginning of the line) temporarily to see if the issue resolves.
  • Always keep a backup of the original fstab file before making changes so that you can easily revert to a working configuration if needed.
  • Seek assistance from Linux forums, communities, or experienced users if you encounter persistent issues as fstab errors can impact system stability.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our How to Mount an SMB (Samba) Share in Linux with cifs-utils guide.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out How to Setup OpenSSH with Keys on Ubuntu 22.04.

View our How to Create a Mapped Network Drive in Windows 10 tutorial.

Learn How to Install and Configure Grafana on Ubuntu 22.04.

View all of our available online tools and converters at Formatswap.com.

How to Install and Configure Apache Tomcat 10 on Ubuntu 22.04

apache tomcat ubuntu splash image

Apache Tomcat 10 is a powerful tool for deploying Java-based web applications, and if you’re running Ubuntu 22.04 you can easily harness its capabilities. In this easy to follow tutorial we’ll walk you through the straightforward process of installing and configuring it on your Ubuntu 22.04 system.

Whether you’re a seasoned developer or new to web development, this guide simplifies the installation and setup. By the end of the tutorial you’ll have Apache Tomcat 10 up and running on your Ubuntu 22.04 machine. This will have you ready to host your Java web applications.

Let’s get started with this quick guide to Apache Tomcat 10 on Ubuntu 22.04. Tomcat 10 will open up a new world of possibilities for your web development projects.

Update and Upgrade Ubuntu 22.04

update ubuntu 22.04

The first step to installing Apache Tomcat is to update and upgrade your system. Use the following apt command.

sudo apt update && sudo apt upgrade -y

Download and Install Java Development Kit

download java jdk

Next we need to install the Java Development Kit (JDK) package. Install the latest version will the apt command below.

sudo apt install openjdk-11-jdk 

Verify Java Version

verify java version

After installing the Java JDK we will want to verify the version, and that it was installed correctly. Use the java command shown below.

java -version

Create a User for Tomcat

create linux user for tomcat

The next step will be to create a Linux user account to manage our Apache Tomcat installation. Use the useradd command to create the user.

sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat 

Download Apache Tomcat 10

download apache tomcat 10

Once we have finished creating our user we will download Tomcat. Use wget to download the latest version with the below command.

wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.13/bin/apache-tomcat-10.1.13.tar.gz

Extract Apache Tomcat

extract apache tomcat

Now that we have downloaded Tomcat we need to extract it. Use the tar command below to extract the archive into the /opt/tomcat folder.

sudo tar xzf apache-tomcat-*.tar.gz -C /opt/tomcat

Executable Files and Permissions

set permissions and make files executable

The next thing we will do is set the permissions of the /opt/tomcat folder.

sudo chown -R tomcat: /opt/tomcat

After you set the permissions you will need to make all of the .sh files in the /opt/tomcat folder executable. Use the following sh command.

sudo sh -c 'chmod +x /opt/tomcat/apache-tomcat-10.1.13/bin/*.sh'

Create Tomcat Users

create a user for tomcat

Next we will create the Tomcat user accounts using the tomcat-users.x file. First create the file with the nano command.

sudo nano /opt/tomcat/apache-tomcat-10.1.13/conf/tomcat-users.xml 

Then add the following text replacing _SECRET_PASSWORD_ with the passwords you wish to use. Save the file when finished.

<!-- user manager can access only the manager section -->
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />
 
<!-- user admin can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />

Allow External Connections to Tomcat

allow external connections in manager context.xml file

After you had created the users you will want to make Apache Tomcat accessible externally. The first thing is to open the context.xml file with nano.

sudo nano /opt/tomcat/apache-tomcat-10.1.13/webapps/manager/META-INF/context.xml

Once the file is open comment out the following section shown in the red box of the above screenshot.

<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

Additionally Edit the Host Manager Context.xml File

allow external connections in host manager context.xml file

Additionally we have to comment out a section of the host manager context.xml file. This is also needed to allow external access. Open the file with nano.

sudo nano /opt/tomcat/apache-tomcat-10.1.13/webapps/host-manager/META-INF/context.xml

Then comment out the following line. After saving the file your Tomcat should be accessible from outside your network.

<!--<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

Create Systemd Service File

create a systemd service file

Next we will created a systemd service file to manage Apache Tomcat. First create the file with the nano text editor.

sudo nano /etc/systemd/system/tomcat.service 

Then add the following text. Save the file after adding it.

[Unit]
Description=Apache Tomcat 10 Web Application Server
After=network.target
 
[Service]
Type=forking
 
User=tomcat
Group=tomcat
 
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
 
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
 
[Install]
WantedBy=multi-user.target

Reload Systemctl Daemon

reload systemctl daemon

After creating the service file we will reload the daemon.

sudo systemctl daemon-reload

As well as start the Apache Tomcat application.

sudo systemctl start tomcat

Check Tomcat Status

check status of tomcat

Next we will check the current status of Tomcat to make sure it started correctly.

sudo systemctl status tomcat.service

Enable Tomcat to Start at Boot

enable tomcat at boot

After that set Apache Tomcat to start at system boot with the systemctl enable command.

sudo systemctl enable tomcat

Configure UFW Firewall

allow tomcat port through firewall

Now we can allow Tomcat through the ufw firewall. Use the following command to allow it.

sudo ufw allow 8080

Test Tomcat Configuration

test apache tomcat

The final step of installing Apache Tomcat is to navigate to the application. Open a web browser and go to http://UBUNTU_IP_ADDRESS:8080/ replacing the IP with the IP of your box. If everything is successful you should see a page similar to the above. You have now successfully installed Apache Tomcat 10 on Ubuntu 22.04.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our How to Setup Nginx as a Reverse Proxy on Ubuntu 22.04 LTS.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our How to Easily Create a Bootable Linux USB Drive using Rufus article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Install and Configure Grafana on Ubuntu 22.04

grafana splash image

In this tutorial you will learn the installation process of Grafana on Ubuntu 22.04. Grafana is renowned for its versatility and powerful data visualization capabilities. It has become an essential tool for monitoring and analyzing data across various industries and applications. Whether you’re a seasoned systems administrator or a curious enthusiast eager to use the potential of Grafana for your data driven needs, this guide will provide you with clear instructions to set up Grafana on your Ubuntu 22.04 system. Let’s dive in and unleash the potential of Grafana for your data visualization and monitoring endeavors.

Install Prerequisite Packages

install prerequisite packages

The first step for installing Grafana is to download and install all of the prerequisite packages. Install them using the apt command below.

sudo apt install apt-transport-https software-properties-common wget

Import Grafana GPG Key

install grafana gpg key

Next we need to import Grafanas repository GPG key. First create a keyrings folder with the mkdir command. Then download the key with the wget command.

sudo mkdir -p /etc/apt/keyrings/

wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null

Add The Grafana Repository

add the grafana repository

Now we will add the stable Grafana repository. Use the echo command to add it to your sources.list file.

echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

Update Ubuntu 22.04

update ubuntu 22.04

Afterwards we will use apt to update Ubuntu 22.04.

sudo apt update

Start and Enable Grafana Service

enable and start grafana service

Next we will start and enable the grafana-server package. Use the systemctl start and enable commands to complete this step.

sudo systemctl start grafana-server

sudo systemctl enable grafana-server.service

Test Grafana Login

login to the test grafana account

Navigate to the login page of your new Grafana installation by navigating to http://SERVER-IPADDRESS:3000 . Replace SERVER-IPADDRESS with the IP address of the server you installed Grafana onto. Then login using the default credentials below.

Username: admin
Password: admin

Start Using Grafana

start using grafana

Once you login you have successfully installed Grafana on Ubuntu 22.04. You can now create a dashboard and get started with Grafana. For more information on getting started see the Grafana Build Your First Dashboard article.

FAQ

What is Grafana, and what is its primary purpose?

Answer: Grafana is an open source platform for monitoring data. Its primary purpose is to visualize and analyze data from different sources, including databases, cloud services, and monitoring systems. This help users gain insights into the performance of their applications and infrastructure.

What data sources can Grafana connect to?

Answer: Grafana can connect to a wide range of data sources, including but not limited to:

  • Time series databases like InfluxDB, Prometheus, and Graphite.
  • Relational databases such as MySQL, PostgreSQL, and Microsoft SQL Server.
  • Cloud monitoring services like AWS CloudWatch and Azure Monitor.
  • Log management systems like Elasticsearch and Loki.
  • Custom APIs through HTTP requests.
  • Many other data sources through community-supported plugins and integrations.

How can I create dashboards in Grafana?

Answer: Dashboards in Grafana are created using the web based interface. Here are the general steps:

  1. Log in to your Grafana instance.
  2. Click on “Create” and then “Dashboard.”
  3. Add a panel to your dashboard.
  4. Configure the panel’s data source, query, and visualization options.
  5. Customize the panel’s appearance and layout.
  6. Add more panels as needed to build a complete dashboard.
  7. Save the dashboard for future use and sharing.

Can Grafana be used for alerting and notifications?

Answer: Yes, Grafana includes alerting and notification features. You can set up alerts based on various thresholds or conditions in your data. When an alert condition is met Grafana can send notifications via various channel, such as email, Slack, PagerDuty, or custom webhooks, helping you to monitor and respond to issues.

Is Grafana suitable for large-scale enterprise environments?

Answer: Yes, Grafana is suitable for both small scale and large scale environments. It is highly scalable and can handle large volumes of data and users. Additionally Grafana supports features like user authentication, access control, and integration with various authentication providers. This makes it a great choice for use in enterprise level environments where security and access control are important considerations.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our 5 Reasons to Switch from Windows 10 to Linux.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our How to Easily Create a Bootable Linux USB Drive using Rufus article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Windows with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Create a Windows 10 Virtual Machine Using VirtualBox on Ubuntu 22.04

install virtualbox splash image

Welcome to our comprehensive tutorial on creating a Windows 10 virtual machine using VirtualBox on Ubuntu 22.04. In this article we will guide you through the step-by-step process of not only installing VirtualBox on your Ubuntu 22.04 system, but also constructing a new virtual machine within VirtualBox. Whether you’re a beginner or an experienced user this tutorial will equip you with the necessary knowledge to set up and configure Windows 10 within a virtualized environment. This will enable you to seamlessly run Windows applications on your Ubuntu system. So, let’s dive in and explore the exciting world of virtualization with VirtualBox!

Update and Upgrade Ubuntu 22.04

update and upgrade ubuntu

The first step is to update and upgrade Ubuntu 22.04. You can do so using the apt command.

sudo apt update && sudo apt upgrade

Install VirtualBox

install virtualbox

Next you will need to install the VirtualBox package as well as the VirtualBox DKMS package. You can install them both with the following command.

sudo apt install virtualbox virtualbox-dkms

Install VirtualBox Extension Pack (optional)

install virtualbox extensions

After installing the two packages you can install the VirtualBox extension pack. This gives you features such as shared clip board, and shared folders within your virtual machine. This step is optional but it is highly recommended.

sudo apt install virtualbox-ext-pack

Add Your User to the User Group

add user to virtualbox group

The final step of the installation process is to add your user account the the vboxusers group. Use the usermod command below to complete this operation.

sudo usermod -a -G vboxusers $USER

Download Windows 10 ISO

Download Windows 10

Now that VirtualBox is installed we can download our ISO that we will use for the virtual machine. In this example I will be using the Windows 10 (64 Bit) installation ISO file. However the Windows 11 process would be virtually the same.

Download Windows 10 (ISO File)

Create a New Virtual Machine with VirtualBox

create new vm with virtualbox

The next step is to open VirtualBox and create a new virtual machine. Simply open the application and click on the “New” button as shown in the screenshot.

Set the Virtual Machines Options

fill out virtualbox config

You will then be asked to choose a name for the virtual machine. Then you will need to select the amount of memory you want available to the virtual machine. Finally select “Create a virtual hard disk now” then press the “Create” button.

Create a Virtual Hard Disk

create the virtual hard drive

On the virtual hard disk creation wizard you will be asked to choose a location, as well as choose the disks size. After you have made your selections click on “Create” to finish.

Power on the Windows 10 Virtual Machine

start the virtual machine

After creating the new virtual machine you will be greeted with this screen showing the Windows 10 VM. Click on the machine and then click “Start” to launch the machine.

Select the Boot Disk

select the iso file

Once the virtual machine starts you will be asked to choose an installation ISO. Select the Windows 10 ISO file we downloaded earlier (or another of your choice). Then click on “Start”.

Start the Windows 10 Installation

start installation process for windows 10

After a few moments you will reach the Windows 10 installation screen. Select a language and click “Next” to continue.

Click Install Now

click install windows 10 now

On the next screen simply press “Install now”.

Windows Product Activation

enter up skip product key

The next screen will ask you if you want to provide a Windows activation key. Either enter your key and press next, or click “I don’t have a product key” to continue.

Select the Version of Windows 10 to Install

select windows version

You will now be asked which version of Windows 10 you would like to install. For this demo I will be selecting “Windows 10 Pro”. After you select it click “Next”.

Accept the License Agreement

accept the licence

Now you will be asked to accept Microsoft’s license terms for the Windows Operating System. Enable the checkbox then click “Next”.

Choose Custom Windows Install

choose custom install

Next you will be asked if you would like to upgrade an existing Windows installation or install a fresh version. Since this is a virtual machine we will want to select “Custom: Install Windows only (advanced)”.

Choose Where to Install Windows

select the disk

After selecting “Custom” you will be asked to choose the location Windows should be installed. Click on the virtual hard disk we created in the earlier, then click “Next”.

Wait for the Windows Installation to Complete

wait for windows 10 to finish installing

Once you reach this screen Windows is installing. Wait for the process to complete successfully.

Finalize the Windows 10 Configuration

follow windows setup prompts

After the base installation finishes you will see this screen. Go through each of the steps and provide your personalization preferences.

Wait for Windows to Configure

wait for final windows 10 setup

Wait for Windows 10 to finish configuring on the virtual machine.

Insert the VirtualBox Guest Additions CD

insert virtualbox guest cd

Once you are able to login to Windows we will want to install the VirtualBox Guest Additions package. To do so simply click on “Devices”, and then “Insert Guest Additions CD image…” shown in the screenshot above.

Open the VirtualBox Guest Additions CD

open guest additions cd

Now that you have inserted the CD it can’t be located in File Explorer under “This PC”. Double click on the CD to open it.

Launch the VirtualBox Guest Additions Installation Wizard

install guest cd

Launch the Oracle VM VirtualBox Guest Additions installer executable found in the CD folder. Follow the onscreen prompts to install the software.

Reboot the Windows 10 Virtual Machine

reboot virtualbox

The final step will be to reboot the virtual machine. Once the machine reboots you have successfully setup a Windows 10 virtual machine using VirtualBox in Ubuntu 22.04.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our guide on How to Install WordPress on Ubuntu 22.04.

Learn How to Permanently Disable Windows Defender.

Check out our Installing Elementary OS: A Comprehensive Guide for Beginners article.

View our How to Install an Nginx RTMP Server in Ubuntu 22.04 tutorial.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Install and Remotely Access Squid Proxy on Ubuntu 22.04

squid splash image

This tutorial provides a comprehensive guide on setting up and remotely accessing the Squid proxy server on an Ubuntu 22.04 system. Squid proxy is a popular caching and forwarding HTTP proxy server that acts as an intermediary between clients and web servers. It enables efficient caching of web content, improves browsing performance, and provides various features for network administrators to manage and control internet access.

By installing and configuring Squid proxy on an Ubuntu 22.04 system, you gain the ability to cache frequently accessed web content, reducing bandwidth usage and improving response times for subsequent requests. Additionally, Squid proxy offers features such as access control, content filtering, and user authentication. This allows you to enforce policies and restrictions for internet access within your network.

The article not only walks you through the installation process of Squid proxy on Ubuntu 22.04 but also provides instructions for remote access. This means you can send your devices traffic to the proxy server from a remote location granting you accessibility and security from anywhere.

Overall, understanding how to install and remotely access Squid proxy on Ubuntu 22.04 empowers you to optimize your network’s performance, enhance security, and efficiently manage internet access for your organization or personal use.

Update and Upgrade Ubuntu 22.04

update and upgrade ubuntu 22.04

The first thing we will need to do to install Squid Proxy is update and upgrade your system. Run the apt update and apt upgrade command below.

sudo apt update && sudo apt upgrade -y

Install Squid Proxy

install squid and apache2-utils

The next thing we need to do is install Squid proxy and Apache utilities. The utilities package will allow us to create a password authentication file for authentication our proxy users. Use the apt command below to install the two packages.

sudo apt install squid apache2-utils

Create a Credential File

touch and create squid passwords file

Now we will create a passwords file and assign the correct permissions. Squid will read this file to authenticate our proxy users. Use the below command to touch and chmod the file.

sudo touch /etc/squid/passwords && sudo chmod 777 /etc/squid/passwords

Create Authentication User

create user and password

Next create the proxy authentication user with the htpasswd command. Replace “username” with the username you want to use for logging into the proxy. After you run the command you will be asked to type and retype the password you wish to use.

sudo htpasswd -c /etc/squid/passwords username

Test Authentication

test the authentication file

Now we can test our proxy authentication file with the basic_ncsa_auth command. Run the following command and confirm you get “OK” as shown in the above image. This means that the credential file is configured properly.

/usr/lib/squid/basic_ncsa_auth /etc/squid/passwords

Backup Squid Config

backup the original squid config

After we create our credentials file we need to make a backup of the squid config. Move it to a temporary location with the command below.

sudo mv /etc/squid/squid.conf /etc/squid/squid.conf.backup

Create Squid Config File

create new squid config file

Now create a new squid config file with the nano command.

sudo nano /etc/squid/squid.conf

Add Lines to Config (Local Network Only)

add to squid config for localnet only

Once the file opens it will be blank and we need to add a few lines. Copy and paste the below config into your squid.conf file. Make sure to change the “acl localnet src 192.168.2.0/24” line to reflect your own IP range. With this configuration you will only be able to access your proxy from within the local network. If you want to access the proxy remotely skip to the next optional step. Otherwise save and close the config file.

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 24 hours
auth_param basic casesensitive off
acl authenticated proxy_auth REQUIRED
acl localnet src 192.168.2.0/24 # RFC1918 possible internal network
http_access allow localnet
http_access deny all
dns_v4_first on
forwarded_for delete
via off
http_port 8888

[optional] Add Lines to Config (Remote)

add to squid config for both wan and lan access

This step is optional, however it will allow you to access the proxy server remotely. To enable remote access replace your config with the lines shown below. Keep in mind you will also have to enable port forwarding in your router for remote access. Save and close the file.

When allowing remote access to your proxy it is recommended to configure a firewall. For guidance on this please see our How to Configure a Firewall in Linux using UFW tutorial.

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 24 hours
auth_param basic casesensitive off
acl authenticated proxy_auth REQUIRED
acl all src 192.168.2.0/24 # RFC1918 possible internal network
http_access allow all
http_access deny all
dns_v4_first on
forwarded_for delete
via off
http_port 8888

Start and Enable Squid Process

start and enable squid

The last step in the installation process is to start and enable the squid proxy service. Use the systemctl command below to complete these steps.

sudo systemctl start squid && sudo systemctl enable squid

Install Curl

install curl on separate machine

Now that the installation is complete we can test our squid proxy server. For this step you will need to install Curl onto a separate machine.

sudo apt install curl

Test the Squid Proxy Server

test the proxy with curl

After you have installed Curl run the following command. Replace “myuser:password” with the username and password you choose when you created the credential file. Additionally replace IP-ADDRESS with the IP of the Ubuntu machine with the squid proxy server.

curl --proxy-user myuser:password --proxy IP-ADDRESS:8888 https://www.google.com

Verify Curl Results

confirm curl response with proxy

If the connection to the proxy server was successful you should see a bunch of text in the Curl response. You have now successfully installed Squid proxy on Ubuntu 22.04.

[optional] Verify the Proxy Requests in the Log

confirm the connection test in the squid access log

If you would like extra verification that Squid is functioning you can check the log file. Use the tail command below and verify you see a new request appear when you run the test Curl command from above.

sudo tail -f /var/log/squid/access.log

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our guide on How to Install WordPress on Ubuntu 22.04.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our Installing Elementary OS: A Comprehensive Guide for Beginners article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Install WordPress on Ubuntu 22.04

install wordpress on ubuntu splash image

In today’s tech age having a powerful and user friendly website is essential for businesses, bloggers, and individuals. WordPress a renowned content management system (CMS), has emerged as the go-to solution for creating stunning websites with ease. If you’re looking to use WordPress on your Ubuntu 22.04 server this article is your comprehensive guide to getting started.

WordPress offers a vast array of themes, plugins, and customizable features that enable you to create a unique online presence. Whether you’re a beginner or a seasoned web developer, WordPress simplifies website creation and management. Best of all it eliminates the need for extensive coding knowledge. By leveraging its intuitive interface and extensive community support, you can effortlessly establish a professional online presence.

In this step by step tutorial, we will walk you through the process of installing WordPress on Ubuntu 22.04. By following these instructions, you’ll be well-equipped to embark on your WordPress journey and start using this dynamic platform. Let’s dive in and empower your web presence with WordPress on Ubuntu 22.04.

Update and Upgrade Ubuntu

Update and Upgrade Ubuntu

The first step to installing WordPress is to update and upgrade your Ubuntu installation. Run the following command.

sudo apt update && sudo apt upgrade -y

Install Required Packages

Install Required Packages

Next you will need to install all of the required packages. Install them using the apt command below.

sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql -y

Login to the Root MySQL Account

Login to the Root MySQL Account

Once you have installed all of the required packages you will need to login to SQL. Use the below mysql command, then enter your user password to login.

sudo mysql -u root -p

Update the Database Records

Update the Database Records

After you get into mysql, run the following four mysql statements. Replace ‘wordpressuser’ and ‘password’ with the username and password you want to use for your mysql user.

CREATE DATABASE wordpress;

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';

FLUSH PRIVILEGES;

Once the mysql statements have been ran, exit the mysql command line with ‘EXIT;’.

EXIT;

Download WordPress

Download WordPress

After running your mysql commands you will need to download WordPress. First navigate to your web directory at /var/www/html.

cd /var/www/html

Then download the latest version of WordPress using the wget command.

sudo wget https://wordpress.org/latest.tar.gz

Extract the WordPress Archive

Extract the WordPress Archive

Next extract the WordPress files from the .tar.gz archive using the tar command.

sudo tar -xvzf latest.tar.gz

Move the Files to the Web Directory

Move the Files to the Web Directory

After the files have been extracted, move them to the root web directory using the mv command.

sudo mv wordpress/* .

Apply Permissions

Apply Permissions

Next apply read/write permission to the folder using the chown and chmod commands.

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

Move the WordPress Config File

Move the WordPress Config File

After applying the permissions, create a WordPress config file based off of the sample file. Use the following command.

sudo mv wp-config-sample.php wp-config.php

Open the WordPress Config File

Open the WordPress Config File

After creating the wp-config.php file you need to open it using the nano text editor, or your editor of choice.

sudo nano wp-config.php

Update the Config Values

Update the Config Values

Now you need to update the three lines highlighted in red. Fill out the DB_NAME, DB_USER, and DB_PASSWORD lines with the values you choose during the mysql step. Once you finish editing these lines, save and close the file.

Edit the Apache Configuration File

Edit the Apache Configuration File

Afterwards open up your Apache configuration file with nano.

sudo nano /etc/apache2/sites-enabled/000-default.conf

Scroll down until you see the line “DocumentRoot /var/www/html”, add the following to the line underneath.

DirectoryIndex index.php index.html

Once you have made your changes save and close the file.

Enable Apache a2enmod

Enable Apache a2enmod

Now we have to enable the Apache extension “a2enmod”. Enable it using the below command. If it was successful you should see “Enabling module rewrite”.

Restart Apache

Restart Apache

Finally we will restart Apache to apply all of our changes. Use the systemctl restart command below.

sudo systemctl restart apache2

Navigate to the WordPress Setup Page

Navigate to the WordPress Setup Page

Now you can open a web browser and navigate to your servers IP address. You can find it by opening a terminal window on Ubuntu and running the “ip a” command. Once you arrive to the page you will be asked to select your language before continuing.

Configure the WordPress Site

Configure the WordPress Site

On the next page you will be asked for the title of your site, your username, password, and email. After you fill out these fields select “Install WordPress” to complete the installation.

WordPress Successfully Installed on Ubuntu 22.04

Wordpress Successfully Installed on Ubuntu 22.04

Once you see this page your WordPress installation is complete. Click “Log In” to begin using WordPress. You have now successfully installed WordPress on Ubuntu Server 22.04.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our How to Setup Nginx as a Reverse Proxy on Ubuntu 22.04 LTS.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our How to Easily Create a Bootable Linux USB Drive using Rufus article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Setup Nginx as a Reverse Proxy on Ubuntu 22.04 LTS

nginx splash

What is a reverse proxy server?

With the rise of cloud computing and distributed systems, it is common to have multiple web servers handling different aspects of a web application. However, managing and directing traffic to multiple servers can be a complex task. This is where setting up a Nginx reverse proxy can come in handy.

A reverse proxy acts as an intermediary between the clients device and one or more web servers. It receives requests from clients and sends them to the appropriate server based on a configuration file. This allows for load balancing and distribution of traffic across multiple servers. This ensures that none of your servers are overwhelmed with requests.

One of the primary benefits of using a reverse proxy is that it enables you to have multiple web servers handling different sections of your website or web application while still appearing as a single website to your users. For example, you could have the main section of your website handled by one Nginx server, while the additional subsections of your website are handled by a separate Nginx server.

This will not only help with managing traffic but also provides an added layer of security by hiding the origin servers from external users. If one of the servers fails, the reverse proxy has the ability to automatically redirect traffic to other healthy servers. This ensures that the website will always remain available and responsive.

Overall a reverse proxy is a powerful tool that can help manage traffic to multiple web servers, provide load balancing, improve security, and ensure high availability of web applications.

Initial Setup

This tutorial assumes that you already have a primary Nginx server set up (reverse proxy server). As well as a second Nginx server with the web app you want to appear on the first. If you need help installing a basic Nginx server, please read our How to install and configure Nginx tutorial.

Overview of Goal

primary nginx reverse proxy web server

For this example the above web server 192.168.2.154 (shown above) will be our primary web server where we will configure the Nginx reverse proxy.

secondary nginx reverse proxy web server

The second web server 192.168.2.155 (shown above) hosts the web application we want to reverse proxy to the first server.

404 not found example reverse proxy

The goal is to be able to access the second web servers content from a subfolder app2/ on the primary server. We want to be able to access the above URL on the primary server and have the blue website content load from the second server. Once we have finished configuring the reverse proxy, we will be able to access the second web servers content using a subfolder on the primary web server 192.168.2.154/app2/.

Connect to the Primary Web Server

To get started connect to the primary web server. In my case this will be the 192.168.2.154 server. Once connected open a new terminal window. Next create a new directory in the /var/www/html/ folder. This is where you will access your secondary web server from. In my case I will use the command shown below.

sudo mkdir /var/www/html/app2

Edit the Nginx Config File

nginx config file

Afterwards we need to edit the /etc/nginx/sites-available/default config file. Open the file in your favorite text editor and navigate to the location / section inside the server { } parentheses as shown above. The command below will open the file with the nano text editor.

sudo nano /etc/nginx/sites-available/default

Add a New Location

add lines to nginx config for proxy_pass

Now we need to add a new location under the first location / block. Use the command block below as an example. Replace FOLDER_NAME with the name of the directory you want the secondary web server accessible from. This is the folder we created in the first step. We also need to replace IP_ADDRESS with the IP of the secondary web server.

location /FOLDER_NAME {
                proxy_pass http://IP_ADDRESS/;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

After adding the location block, close and save the file with Crtl+X.

Restart Nginx

Next we need to restart the Nginx web server to apply our configuration changes. To do this we use the systemctl command below.

sudo systemctl restart nginx.service

Test the Nginx Reverse Proxy

successful nginx reverse proxy test

Now we will need to test that the reverse proxy is working. We will navigate to our subfolder we created earlier using the primary web server 192.168.2.154/app2/. Assuming the Nginx config was set up correctly your second web servers content should appear. You have now successfully configured a reverse proxy using the Nginx web server.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our 5 Reasons to Switch from Windows 10 to Linux tutorial.

Learn How to Generate Images From Text Prompts with Python and TensorFlow.

Check out our How to Setup OpenSSH with Keys on Ubuntu 22.04 tutorial.

View our Deep Learning Image Style Transfer Tutorial Using Neural Style Pt tutorial.

Learn How to Setup Nginx as a Reverse Proxy on Ubuntu 22.04 LTS.

Learn How to Install an Nginx RTMP Server in Ubuntu 22.04.

View all of our available online tools and converters at Formatswap.com.

How to Install an Nginx RTMP Server in Ubuntu 22.04

nginx rtmp splash

In this tutorial, you will learn how to install the Nginx web server and enable the RTMP (Real-Time Messaging Protocol) module on any Ubuntu-based distribution. The RTMP protocol is a robust and efficient means of transmitting live video streams from your computer to the internet. This makes it an indispensable tool for content creators and streamers. With this tutorial, you can master the installation and configuration of Nginx with the RTMP module. This will allow you to broadcast your live video streams with ease.

Nginx is an open-source web server that is known for its efficiency, scalability, and reliability. It is widely used by web developers and system administrators to serve dynamic web content, reverse proxy, load balance, and cache HTTP requests. The Nginx RTMP module supports live streaming, making it an all-in-one solution for web developers and content creators.

RTMP is widely used by video streaming services such as YouTube, Twitch, and Facebook Live. With Nginx and the RTMP module, you can create your own video streaming service or broadcast your content on existing platforms. Whether you are a web developer looking to add live streaming to your website or a content creator looking to broadcast your content to a global audience. This tutorial is an excellent starting point to get you up and running with Nginx and the RTMP module.

Update and Upgrade Ubuntu

update and upgrade ubuntu

The first thing you will need to do is update and upgrade Ubuntu. You can do this with the following apt command.

sudo apt update && sudo apt upgrade

Install Nginx Web Server

install nginx web server

Next install nginx using apt.

sudo apt install nginx

Enable the Ubuntu Universe Repository

enable universal repository

We will now need to enable the Ubuntu Universe Repository. It is usually enabled by default but it is a good idea to verify. This will allow us to install the Nginx rtmp module.

sudo add-apt-repository universe

Install the Nginx RTMP Module

install nginx rtmp module

After you have enabled the repository, install the Nginx RTMP module using the command below. This will allow us to stream RTMP video using the Nginx web server.

sudo apt install libnginx-mod-rtmp

Open the Nginx Config File

open nginx config

Now we will need to make a few configuration changes in the nginx config file. Open it using the nano text editor.

sudo nano /etc/nginx/nginx.conf

Add Lines to Config

edit nginx config

Once you have opened the config file, scroll to the bottom and add the following lines. After adding them, save and close the file.

rtmp {
	server {
		listen 1935;
		chunk_size 4096;

		application live {
			live on;
			record off;
		}
	}
}

Restart Nginx Web Server

restart nginx

The last step of the installation process is to restart Nginx. Do this using the following systemctl command.

sudo systemctl restart nginx

Create a Test RTMP Stream with OBS

At this point we have finished the installation and configuration of a RTMP streaming server using Nginx. We now need to test the server. In this article I will be using OBS Studio to demonstrate the test stream. Below you will see instructions for installing OBS on both Windows and Linux. Choose the option that matches the OS of the system you will be streaming from.

Install OBS Studio (Ubuntu)

install obs studio ubuntu

Run the following command to install OBS Studio on Ubuntu.

sudo apt install obs-studio

Install OBS Studio (Windows)

To install OBS on Windows download it from the link below. Then launch the installer and follow the prompts.

Download OBS Studio

Open OBS Studio

open obs

After you have finished installing OBS Studio we can test the stream. Launch the program to get started.

Add a New Source

add a new source obs

Next click on the “+” button in the lower left to add a new source. I will be using the screen capture for this example, however feel free to use any source.

Choose Display

choose a display obs

Next it will ask which screen you would like to use. Generally it is on the correct option by default, but change it if it looks incorrect. Then click on the “OK” button.

Open OBS Settings Menu

open settings menu obs

Then we will need to open the OBS settings menu. Click on “Settings” in the lower right hand corner.

Stream to a Custom RTMP Server with OBS

stream to a custom rtmp server obs

Once the settings menu opens click on the “Stream” tab on the left hand side. Once you are on the tab change all three fields highlighted in red. Change the service drop down to “Custom…”, the Server to “rtmp://NGINX_SERVER_IP/live”, and the Stream Key to “test”. Then click on “OK” to save the changes.

Start the Test Stream

start streaming obs

After saving your streaming settings click on the “Start Streaming” button to begin the RTMP stream.

Open a Network Stream in VLC

open network stream vlc

Now we will test the RTMP stream using VLC Media Player. Launch the program then navigate to the “Media” tab in the top bar. Then click on “Open Network Stream…”.

Enter Network Stream URL

enter network url vlc

Enter the following into the box highlighted in red replacing “localhost” with your Nginx servers IP address. Then click on the “Play” button to start watching the stream.

rtmp://NGINX_SERVER_IP/live/test

Verify the RTMP Stream

verify rtmp stream

Verify that you can see your OBS stream. If you are able to see it then you have successfully streamed to a Nginx RTMP server using OBS Studio.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our 5 Reasons to Switch from Windows 10 to Linux.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our How to Easily Create a Bootable Linux USB Drive using Rufus article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Windows with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Install and Configure Oh My Zsh in Linux

ohmyzsh splash

Using this tutorial you will learn how to install the popular bash shell alternative Oh My Zsh. Most Linux systems come preinstalled with the bash shell. Oh My Zsh adds many features compared to what you would find in this shell. Integrating Oh My Zsh into your workflow can provide numerous benefits. It’s easy to install, customize, and use, making it a must have tool for anyone looking to optimize their terminal experience. This will optimize and improve the speed and efficiency of your terminal based workflow.

Benefits of Oh My Zsh

One of the main benefits is spelling correction. While the standard bash shell offers this feature, Oh My Zsh does more efficiently and accurately. Another reason to use Oh my Zsh is the ability to easily install custom themes. There are hundreds of pre-built themes available for download on the projects GitHub page. Theming is also possible in the standard bash shell, however you are limited in the amount of customization you can easily achieve. The primary reason I recommend people switch to Oh My Zsh is its advanced command history ability. You can customize the shells history to your specific liking. This makes re-running past commands indefinitely easier. Don’t miss out on the chance to enhance your terminal with Oh My Zsh.

Update and Upgrade

update system

In this tutorial I will be using Ubuntu 22.04 to install the shell. However any Linux distribution that supports bash will support installing Oh My Zsh.

sudo apt update && sudo apt upgrade

Download and Install Curl

install curl

Next you will need to install the application curl. This will allow us to download and install Oh My Zsh using a curl command.

sudo apt install curl

Download and Install Zsh

install zsh

After installing curl you need to download the base zsh shell program. Install it by running the following apt command.

sudo apt install zsh

Installation Options

You are able to install Oh My Zsh using either the wget, fetch, or curl command. In this example I will be using wget. Use whichever method you prefer and run the command.

wget:

sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

fetch:

sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

curl:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Download Oh My Zsh

download ohmyzsh

After running the command to download Oh My Zsh you will need to change it to your default shell. Type “y”, then press “Enter” to confirm the change.

sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Installation Successful

zsh successful install

You will see the following screen after Oh My Zsh finishes the installation process. The shell is almost ready for use. We just need to verify the installation and make a few edits to the zshrc configuration file. Press “Ctrl+C” twice to exit the Oh My Zsh installer.

Verify the Zsh Installation

verify zsh

Run the “zsh –version” command and verify that you have zsh 5.8 or newer.

zsh --version

Set Default Shell to Zsh

set shell to zsh

Set zsh as the default shell using the “chsh” command.

chsh -s $(which zsh)

Logout to Apply Changes

logout linux

Now you will need to logout of your user account to apply the new changes. Run the “pkill” command below. Once you have logged out, log back in and reopen your terminal.

sudo pkill -SIGKILL -u [your username]

Verify Current Shell

verify current shell

Next verify that your shell is set to zsh using the command below. You should see “/usr/bin/zsh” as the commands output.

echo $SHELL

Verify Shell Version

verify shell version

Now verify that the correct version of zsh is set as your default shell. You should see version 5.8 or newer.

$SHELL --version

Open the Oh My Zsh Config File

nano ~/.zshrc

Next we will customize the shell using the “.zshrc” file located in the home directory. Open the Oh My Zsh configuration file using the command below.

nano ~/.zshrc

Set a Oh My Zsh Theme

set a theme oh my zsh

Now you will want to set a theme. Locate the “ZSH_THEME” and modify it to the theme name of your choice. Above I have set my theme to “agnoster” as it is one of my personal favorites. You can view the full list of available themes to choose from on the Oh My Zsh Github page. Save the file when you are finished with your changes.

Apply the Configuration

source the zshrc config file

Once you are finished editing the zshrc config file you will need to apply the changes. Run the command below, then reopen your terminal.

source ~/.zshrc

Verify Oh My Zsh Theme

test theme

If everything worked correctly you will see your new theme. You have now successfully installed Oh My Zsh, and configured a theme. If you are interested in adding plugins to echance your shells experience even further, visit the plugins page on the Oh My Zsh Wiki.

Conclusion

In conclusion, with the help of this article you now have the tools to effortlessly set up and customize Oh My Zsh in your Linux environment. Say goodbye to mundane terminal sessions and hello to a more productive, customizable, and user-friendly shell experience.

Questions?

If you have any questions or comments feel free to leave them below.

Recommended By Our Editors

View our 5 Reasons to Switch from Windows 10 to Linux.

Learn How to Configure a Firewall in Linux using UFW.

Check out How to Setup OpenSSH with Keys on Ubuntu 22.04.

View our Deep Learning Image Style Transfer Tutorial Using Neural Style Pt tutorial.

Learn How to Create a Mapped Network Drive in Windows 10.

View all of our available online tools and converters at Formatswap.com.

How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH

sftp splash

In this article you will learn how to enable and connect to the SFTP server in OpenSSH. With SFTP (Secure File Transfer Protocol) you can easily transfer files over the internet using SSH. We will be using Ubuntu 22.04 for our server, however any version of Linux should work.

This guide will use password authentication with IP firewall restriction. This will prevent anyone besides those who you want accessing the box via SSH or SFTP. If you want the highest level of security possible you will want to enable keys in OpenSSH before following this guide. Learn how to enable keys with our How to Setup OpenSSH with Keys on Ubuntu 22.04 tutorial.

SFTP vs FTP

It is important to mention that SFTP is not the same as FTP. One of the main differences is while they both transfer files, only SFTP encrypts the data during transit. Another difference is FTP is unable to benefit from public key files for authentication. Using public keys with SFTP increases security by encrypting the transfer data stream. If your aim is security then it is highly recommended you use SFTP versus FTP. Now that I have described the differences lets move on to configuring and connecting to an SFTP server in OpenSSH.

Update and Upgrade Ubuntu

update and upgrade ubuntu

The first thing you need to do is update and upgrade your Ubuntu installation. Open a terminal and type the following command. Afterwards press “Y” to confirm.

sudo apt update && sudo apt upgrade

Install OpenSSH

install open-ssh

After your system has finished updating you will need to install the OpenSSH server software. OpenSSH provides encrypted file transfer for file transfers and remote logins. Install the software using the apt command.

sudo apt install openssh-server

View SSH Status

view ssh status

Next you need to verify that OpenSSH is installed on your system and actively running. Use the below command and confirm that you see “active (running)” on the third line.

sudo systemctl status ssh

If SSH does not show as active and running it may be disabled. Run the following command to enable and start the OpenSSH server.

sudo systemctl enable ssh && sudo systemctl start ssh

Create New User

create a new user

Now you will need to create a new user for logging into the SFTP server. Run the adduser command then type a password. You can skip the other fields if you wish. Finally press “Y” to confirm.

sudo adduser sftpuser

Create New Group

create a new group

Afterwards we will create a new group for our sftpuser. We will configure SSH to give SFTP access to any user in this group. Run the addgroup command to proceed.

sudo addgroup sftpusers

Add User to Group

add user to group

Next we need to add the user to the new group. Run the usermod command to add the sftpuser to the sftpusers group.

sudo usermod -a -G sftpusers sftpuser

Change User’s Home Permissions

change users home permissions

Then we will set new permissions on the sftpuser’s home directory. This will allow the SFTP server to access these files. First execute the chown command followed by the chmod command. The sftpuser’s home will be the folder you access when you connect to the SFTP server.

sudo chown root: /home/sftpuser
sudo chmod 777 /home/sftpuser

Edit the SSH Config File

Next we need to edit the sshd_config file and edit a few lines. Open the configuration file using the nano text editor as shown below.

sudo nano /etc/ssh/sshd_config

Locate the Subsytem Line

locate subsystem line

After you open the file scroll down and look for the Subsystem line. Once you locate the line comment it out using the “#” symbol as shown below.

#Subsystem      sftp    /usr/lib/openssh/sftp-server

Add New Lines

Now that you have commented out the Subsystem line you need to add a few additional lines. Paste the following underneath the line you commented out. Your sshd_config file should match the screenshot above. After the lines have been added save and close the file using “Ctrl+X”.

Subsystem sftp internal-sftp

Match Group sftpgroup
     ChrootDirectory %h
     X11Forwarding no
     AllowTCPForwarding no

Restart SSH

restart ssh

To apply our changes we will restart ssh. Use the following service command.

sudo service ssh restart

Configure the Firewall

The next step is to configure the firewall using UFW to control access to our SFTP server. Start by denying all incoming traffic, and allowing all outgoing.

sudo ufw default deny incoming
sudo ufw default allow outgoing

Allow SSH (All IP’s)

allow ssh

You have two options when allowing SSH through the firewall. You can either allow any IP to access port 22 (not recommended). Or you can only allow specific IP(s) through the firewall. I recommend the section option as it offers higher security. If you want to allow any IP run the following command.

sudo ufw allow ssh

Allow SSH (Specific IP’s)

allow specfic ip

If you want to only allow specific IP’s to access the server run the following command for each IP you want to have access. You need to replace “IP-ADDRESS” with your own IP. This is highly recommended as it offers the highest level of security.

sudo ufw allow from IP-ADDRESS to any port ssh

Enable UFW

enable ufw

After you have allow the IP’s (or everyone) who you want to have access you will need to enable UFW. Run the following command.

sudo ufw enable

Check Firewall Status

check firerwall status

The last step is to check the firewall status and verify your configuration. Check it using the ufw status command. If you allowed access to only specific IP’s you will see them in the “From” column.

sudo ufw status

Connecting to the SFTP Server

Finally we can test our connection to the SFTP server. The first thing you will need is a FTP client. I recommend downloading FileZilla. This is the software we will use in this tutorial. You can install it using the following apt command.

sudo apt install filezilla

Edit Site List

edit filezilla site list

Open Filezilla and click on the site manager button in the upper left hand corner.

Add a New Site

add filezilla site

Type Connection Information

add filezilla connection information

Confirm Host Key Prompt

confirm filezilla hostkey

Verify Connection

verify filezilla connection

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our 5 Reasons to Switch from Windows 10 to Linux.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out How to Setup OpenSSH with Keys on Ubuntu 22.04.

View our How to Mount an SMB (Samba) Share in Linux with cifs-utils tutorial.

Learn How to Use the Alias Command in Linux.

View all of our available online tools and converters at Formatswap.com.