Ubuntu Linux or any Debian-based distros can be a great gaming platform if set up correctly. In this guide, I will guide you to optimize your Ubuntu system with practical methods to maximize FPS, reduce latency, and ensure seamless gameplay by fine-tuning settings, leveraging advanced gaming tools, and configuring your system effectively. Whether you’re playing AAA titles on Steam or experimenting with Wine for non-native games, this guide covers everything you need to be optimized before using Ubuntu for gaming. 😉
Changing the Refresh Rate of the Monitor
Changing your monitor’s refresh rate can enhance gaming performance by providing smoother motion and lower input lag, which is vital for competitive gaming where every millisecond matters. For that;
- Open Settings in your Ubuntu machine and in the Display tab, click on Refresh Rate as seen in the below screenshot.
- Choose the highest value in the refresh rate. For example 144hz.
You can also set the highest refresh rate via the terminal. To do that; open the terminal and type the following to list available resolutions and refresh rates:
xrandr
This command’s output will show the available refresh rates and resolution. For example, if there is 144hz available and you need to change to it, use the below command:
xrandr --output HDMI-1 --mode 1920x1080 --rate 144
To make this setting permanent, add the command to your startup applications.
Installing NVIDIA drivers and Configuring it
Installing the proprietary NVIDIA driver to optimize performance and access advanced features is an essential step when optimizing Ubuntu for gaming. In this step, we install those drivers and then we configure NVIDIA Settings to prioritize high frame rates by setting the ideal resolution, and refresh rate, and enabling performance-enhancing options while disabling V-Sync for potentially higher FPS.
- Install the proprietary NVIDIA driver:
sudo apt install nvidia-driver-525
- Open NVIDIA Settings:
nvidia-settings
- In the “X Server Display Configuration” tab:
- Set the preferred resolution and refresh rate.
- In the “OpenGL Settings” tab:
- Enable “Allow Flipping” and “Use Conformant Texture Clamping”.
- Disable “Sync to VBlank” for maximum FPS.
Disable Mouse Acceleration
Disabling mouse acceleration creates consistent sensitivity, which enhances aiming accuracy. This provides better control and boosts performance in games that demand precise movements, like first-person shooters. You can refer to the YouTube video below for an example of its impact on gaming:
The easiest way to disable Mouse Acceleration in Ubuntu is to go to Mouse & touchpad in Settings and then toggle off the button next to Mouse Acceleration.
If you need to disable Mouse Acceleration via the Ubuntu terminal; follow the steps:
- Open the terminal and disable mouse acceleration temporarily:
xset m 0 0
- To make this setting permanent, create a configuration file:
sudo nano /etc/X11/xorg.conf.d/50-mouse-acceleration.conf
- Add the following to the file:
Section "InputClass"
Identifier "My Mouse"
MatchIsPointer "yes"
Option "AccelerationProfile" "-1"
EndSection
- Restart the X server:
sudo systemctl restart display-manager
Or you can use the Gnome Tweak Tools to disable mouse acceleration by going to the Keyboard & Mouse option and changing the Acceleration Profile to Flat.
Deactivating Compositor
Disabling the compositor is a temporary fix for gaming. It manages visual effects like animations and transparency, which can use up CPU and GPU resources. Turning it off lets games render directly, reducing latency and improving frame rates. Remember to re-enable it after gaming to restore normal desktop functions.
You can disable the compositor on Ubuntu Linux by the command:
gsettings set org.gnome.desktop.interface enable-animations false
To enable it after gaming, you can execute the command: gsettings set org.gnome.desktop.interface enable-animations true
Optimising Ubuntu Kernel for Gaming
Newer kernels generally offer improved support for the latest hardware, such as CPUs, GPUs, and other devices. This enhancement can result in better driver stability, performance, and compatibility with modern gaming hardware. Upgrading the kernel brings substantial advantages, and additional tweaks to kernel settings can further enhance gaming performance.
Before upgrading your Kernel, it’s recommended to review these helpful resources:
1. How to Update the Linux Kernel in Ubuntu?
2. What Stable Kernel Should I Use?
3. Fine-Tuning the Ubuntu 24.04 Kernel for low latency, throughput, and power efficiency
To install a newer kernel, execute the commands below in your Ubuntu Linux terminal:
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt update
sudo apt install mainline
mainline
(Select and install the latest stable kernel)
After installing the newer stable kernel, adjust the kernel parameters such as vm.swappiness, kernel.sched_latency_ns, and kernel.sched_min_granularity_ns in the sysctl.conf file.
To do this, first ensure the sysctl is installed on your system. You can check it or install it using the command: sudo apt install sysctl -y
Then, open the file /etc/sys.conf by executing the command:
sudo nano /etc/sysctl.conf
Add the following lines to this file:
vm.swappiness=10
kernel.sched_latency_ns=6000000
kernel.sched_min_granularity_ns=750000
After adding the lines save the file and execute the below command to apply the settings to the Kernel:
sudo sysctl -p
Using a Custom Kernel for Gaming
A custom kernel, such as Liquorix, or Xanmod, can enhance gaming performance on Ubuntu. These kernels are specially optimized for gaming, leading to reduced latency, increased frame rates, and better CPU scheduling. However, it is essential to be aware that using custom kernels may occasionally cause instability or compatibility problems. In this tutorial, we will use Liquorix to enhance gaming performance on Ubuntu Linux. You can also explore other options after doing some research.
Test each kernel to see how they perform with gaming. You can also conduct benchmark tests for each one. The best kernel for you will depend on your hardware, the games you play, and your personal preferences.
Author’s Recommendation
You can find a sample installation of the Custom Kernel: Liquorix in this YouTube video:
Using Game Mode Software
Game Mode is a tool created to improve gaming performance on Linux systems. Using it prioritizes game processes, optimizes CPU performance, and reduces background interference when playing games on your Ubuntu machine. To use GameMode on Ubuntu, install it first using the below command:
sudo apt install gamemode
and then manually launch games using the gamemoderun
command like the below command:
gamemoderun <game_name>
Reference: https://github.com/FeralInteractive/gamemode
Tweaking CPU Governor
To enhance gaming performance in Ubuntu, change the CPU governor. It controls processor clock speed and voltage based on workload. Ubuntu defaults to a balanced governor prioritizing power efficiency over performance.
Switching to the “performance” governor can lead to significant improvements in gaming, where maintaining high performance is essential. This setting allows the CPU to operate at maximum clock speed, delivering the power needed to manage demanding games.
To do that install cpufrequtils package, which provides tools for managing CPU frequency scaling. first by executing the command:
sudo apt-get install cpufrequtils
Then create a string that sets the GOVERNOR
variable to “performance in the cpufrequtils service configuration file “/etc/default/cpufrequtils” by the command:
echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
Now, apply the new changes by restarting cpufrequtils service:
sudo systemctl restart cpufrequtils
Adjusting I/O Scheduler
Games frequently load significant amounts of data from the disk. An optimized I/O scheduler can reduce waiting times during loading screens, enabling you to start playing more quickly.
Reference: Improving Linux System Performance with I/O Scheduler Tuning
The following adjustment is a simple yet effective way to potentially enhance your gaming experience on Ubuntu by optimizing how your system handles disk operations:
Identify your drive name with the lsblk command:
lsblk
Execute the below command after replacing the exact disk name that we found using lsblk command:
echo 'deadline' | sudo tee /sys/block/nvme0n1/queue/scheduler
In my case, the drive is nvme0n1, so I used nvme01 in the command. Use the correct one according to yours.
This setup can greatly enhance gaming performance on your Ubuntu computer. Using tools like Proton, Steam Play, and Lutris, you can play many more games than just those available natively for Linux. With the correct configuration, Ubuntu can be an excellent platform for gamers, in addition to being suitable for developers and servers.
🏍️….. Happy gaming! 🏎️……