First of all, you will need to go to the directory with the OpenVPN configuration file (.ovpn)
Use the command that will give root access for your Linux distribution. (For eg: sudo, su, doas, etc.)
sudo openvpn --config yourfile.ovpn
You will need to use your Terminal to do other stuff so, you can use this commands to run OpenVPN process in background.
First, click CTRL + Z to suspend the process.
Then, type in jobs
If you have other process in the background then it will show multiple processes else, it will show like this:
rafled@Ubuntu:~$ jobs + Stopped sudo openvpn --config Your_Open_VPN_file.ovpn rafled@Ubuntu:~$
Then, you type in the following command:
Here, the %1 represents the number of your task. Eg, if your task is + then, you type in bg %4.
You can verify that the process is running by typing in jobs which will give output:
rafled@Ubuntu:~$ jobs + Running sudo openvpn --config Your_Open_VPN_file.ovpn & rafled@Ubuntu:~$
Terminating the task
To turn off OpenVPN or to terminate the task, use the following command
rafled@Ubuntu:~$ fg %1 sudo openvpn --config rafled_network.ovpn
This will bring your background process to foreground. (Here, the %1 represents the number of your task. Eg, if your task is + then, you type in bg %4.)
Then, hit CTRL + C to end/terminate the process.