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 Setup OpenSSH with Keys on Ubuntu 22.04

ssh key splash

In this tutorial you will learn how to setup a SSH server to use a public key pair on Ubuntu. SSH is a secure protocol used for remotely administrating servers. We will be using OpenSSH to setup the server. SSH servers are great as they allow you to easily remote into any machine and execute commands. With public key authentication you get robust security. It is generally recommended that all users running an SSH server should enable key based authentication. You also don’t have to remember passwords when using key based authentication. For this tutorial we will be using Ubuntu 22.04 server, but you should be able to use any Linux operating system.

Generate Key Pair

generate key pair

The first step is to generate a key pair on your client machine. Type “ssh-keygen” and press “Enter”. If you get an error you may have to install the Openssh server as shown below.

sudo apt install openssh-server

Select Key Save Location

select key save file location

Next you will be asked to choose a save location for the key. Press “Enter” to use the default, or type a path and filename for the key.

Set a Key Password (optional)

select password

You will then be asked if you want to set a key on the password. This improves security but will require you to enter the password every time you connect to the SSH server. Either type a password or press the “Enter” key twice to not use a password.

Key Generated Successfully

key generated

Now you will see a message telling you that the key pair has been generated successfully. It will also list the fingerprint and the save location for the key.

Copying Public Key

copy the public key

Next we will copy the newly created key to your SSH server. Type in the following command to copy the key.

ssh-copy-id username@ssh-server-ipaddress

Enter the SSH Users Password

optionally select password for key

The server will then ask you to type in the password for the SSH user. Additionally if you set up a password on the key pair, you will also be prompted to type that.

Keys Successfully Added

keys added message

After typing your credentials you will be shown a screen telling you that the key has been successfully added.

SSH into the Server

ssh into the server

Now that the key has been added to the SSH server we need to connect back to the server. Connect to it using the SSH command as shown above.

Edit the OpenSSH Config File

edit the openssh config

Once you are connected to the server you will need to edit a file. Open the sshd_config file using the nano text editor.

sudo nano /etc/ssh/sshd_config

Disable Password Authentication

disable password authentication

Now that the file is open, use “Ctrl+W” to search for the line “PasswordAuthentication”. Once you locate the line change it from “PasswordAuthentication yes” to “PasswordAuthentication no”. This will cause the SSH server to only log you in using your key.

Save OpenSSH Config File

save openssh config

Next simply press “Ctrl+x” then the “Y” key to save the config file.

Restart OpenSSH Server

restart openssh server

Finally we will need to restart the ssh service on the server. Run the following command to complete this action.

sudo systemctl restart ssh

After the SSH service restarts, you will need to disconnect from the SSH server.

Test the SSH Connection

test ssh connection

Now we will test that we are able to login to the SSH server using our key pair. Simply try to reconnect to the SSH server. You will be automatically logged in if you don’t have a password on the key pair. Else you will need to enter the password you created for the key.

OpenSSH with a Key Pair is Enabled

successful key ssh

If you are able to connect to the SSH server then you have successfully setup a key for OpenSSH. Remember to keep the key pair in a secure location. Anyone with access to it would be able to login to your server.

SFTP Server (optional)

You can also enable secure file transfer with SFTP using OpenSSH. If you would like to activate the server view our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Additional Questions?

If you have any additional questions or thoughts feel free to comment them below.

Related Resources

View our list of The Top 10 Programming Languages to Learn in 2022.

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

Click here to learn How to Install MySQL on Ubuntu Server 22.04 LTS.

View all of our Linux Articles and Tutorials.

Learn How to install and configure Nginx – Ubuntu 20.04.

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

How to Mount an SMB (Samba) Share in Linux with cifs-utils

cifs-utils header image

In this tutorial you will learn how to use the CIFS-UTILS program to mount network shares. You will also learn how mount the file shares at boot. This allows you to avoid typing your credentials, as well as avoiding the use of the mount command when you turn on the system. With CIFS-UTILS you will be able to easily access files from a SMB share on your network. I will be using Ubuntu 22.04 LTS throughout this tutorial. However it is fine if you have a different version, as this guide will work on any Ubuntu based Linux distribution.

Update and Upgrade Ubuntu

update and upgrade ubuntu

The first thing you will need to do is update and upgrade your Ubuntu installation. Type in the following command and press Enter.

sudo apt update && sudo apt upgrade
install cifs utils

Now you will see a window asking you if you want to continue. Press “Y” and then Enter.

Install CIFS-UTILS

install cifs utils

Afterwards you will need to install cifs-utils. This is a program that allows you to easily mount different file shares on Linux. Type in the following command to install it.

sudo apt install cifs-utils

Create a Mount Directory

make share mount folder

Next you need to create a folder to mount the SMB share. You can create a folder in either /mnt/ or /media/.

sudo mkdir /media/Share
or
sudo mkdir /mnt/Share

Navigate to the Home Folder

cd to home folder

Now navigate to your home folder.

cd ~/

Create the Credentials File

create creds file

Once you are in the home folder you need to create a credentials file. A credentials file is vastly more secured versus providing the password and username in plain text.

nano .creds
enter user and pass cifs-utils

Now type your username and password in the format above. Once you have typed your credentials, press “Ctrl+X” then “Y” to save and quit the text editor.

Apply Permissions

apply permissions to creds file

Next we will apply the permissions to the credentials file. For security reasons you only want root to be able to read and write the file. Enter the command below to apply the changes.

sudo chown root: .creds && sudo chmod 600 .creds

Mount the SMB Share

mount smb share

Finally you will mount the SMB network share. Enter the below cifs mount command replacing the credential directory, IP address, mount location, and share name with your own.

sudo mount -t cifs -o credentials=/home/USERNAME/.creds,dir_mode=0755,file_mode=0755 //IPADDRESS/ShareName /mnt/Share

After you run the command you can navigate to the mount folder to view the network share that you have added. You have now successfully mounted a SMB network share using cifs-utils.

Auto Mounting

If you only use the mount command, your network share will no longer be mounted when you reboot. We will edit the fstab file and add a few entries. This is the file that defines what file systems are mounted at boot. Continue reading below to make the share persistent.

Edit the fstab File

edit fstab file

First we need to open the fstab file. Type in the following command to edit it.

sudo nano /etc/fstab

Add fstab Entries

mount cifs share

Now you will want to add a new line for mounting your cifs share. Use the code below as an example of what to type, replacing the credentials, IP, and share name with your own.

//IPADDRESS/ShareName  /mnt/Share  cifs  credentials=/home/USERNAME/.creds,file_mode=0755,dir_mode=0755 0  0

Reboot PC

reboot pc

The last step will be to reboot your PC. After rebooting you will see the network share mounted at /mnt/ShareName or /media/ShareName depending on where you created the folder. Thank you for reading the tutorial. If you are interested in similar technology tutorials check out some of our articles below.

Questions?

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

Related Resources

View our How to Permanently Disable Windows Defender article.

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

Click here to learn How to install and configure Nginx – Ubuntu 20.04.

View our Programming Articles and Tutorials.

Learn more cool things in Linux with our Linux Tutorials.

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