Skip to content

Linux »

Tweaks for a better performance

Ubuntu, by default, provides cool desktop environment with some default settings which may consume much resource in the system. Tips here are to speed up Ubuntu, and they are valid for most versions of Ubuntu and can also be applied in Linux Mint and other Ubuntu based distributions.

Last update: 2022-06-22

Disable animation#

Ubuntu comes with cool effects, but it consumes system resource. Turn it off is a good way to increase system performance.

Open a terminal and enter this command:

gsettings set org.gnome.desktop.interface enable-animations false

Reduce startup applications#

First make all startup applications visible, because in Ubuntu, most of them are hidden by default:

cd /etc/xdg/autostart/
sudo sed --in-place 's/NoDisplay=true/NoDisplay=false/g' *.desktop

Now check the Startup Applications, uncheck what you don’t need, for example:

  • Evolution Alarm
  • Orca Screen Reader
  • Ubuntu Report
  • Update Notifier

Delay the execution by adding sleep x; before the execution command of the applications.

Add user to sudoers#

To skip entering password on sudo command, add current user to sudoers with the rule NOPASSWD:

sudo bash -c "echo '$USER ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/$USER"

Use a faster installation method#

Mirror server

Ubuntu contacts to many repos to download, update its packages. Choose the best mirror server is a good way to speed up system update or application installation.

In Software & UpdatesUbuntu SoftwareDownload From and choose Select Best Server.

No language translation

Suppressing the language translation while updating will slightly increase the apt update speed. To do that, open the following file:

sudo nano /etc/apt/apt.conf.d/00aptitude

And add the following line at the end of this file:

Acquire::Languages "none";

Use apt-fast

apt-fastis a shell script wrapper for apt-get that improves updated and package download speed by downloading packages from multiple connections simultaneously. Install apt-fast via official PPA using the following commands:

sudo add-apt-repository ppa:apt-fast/stable && \
sudo apt update && \
sudo apt install -y apt-fast

Automatic installation

First, add new repo to source list:

sudo bash -c 'echo "deb bionic main" > /etc/apt/sources.list.d/apt-fast.list'

then use non-interactive method:

sudo apt-key adv \
    --keyserver \
    --recv-keys A2166B8DE8BDC3367D1901C11EE2FF37CA8DA16B && \
sudo apt update && \
sudo DEBIAN_FRONTEND=noninteractive apt install -y apt-fast

Add alias for apt-fast:

echo 'alias sudo="sudo "' >> ~/.bash_aliases && \
echo 'alias apt=apt-fast' >> ~/.bash_aliases && \
echo 'alias apt-get=apt-fast'  >> ~/.bash_aliases && \
sudo bash -c 'echo "alias apt=apt-fast" >> /root/.bash_aliases' && \
sudo bash -c 'echo "alias apt-get=apt-fast"  >> /root/.bash_aliases'

Source the bash file if you want the alias gets effective immediately:

source ~/.bash_aliases

Disable unattended update#

Ubuntu has a feature named Unattended Upgrades, which installs the latest security (and others) updates automatically whenever they are available. It comes pre-installed and enabled by default in the recent Ubuntu versions. While this feature helps to keep the Ubuntu system up-to-date, it is also quite annoying sometimes.

To disable unattended upgrades on Ubuntu and its derivatives, run:

sudo dpkg-reconfigure unattended-upgrades

Then choose No and hit ENTER to disable unattended upgrades.

Change network connection priority#

If machine is connected to Wi-Fi and Ethernet simultaneously, here is a method to set priority connection.

Install ifmetric tool which can be used to change the metric of any interface:

sudo apt install -y ifmetric

To use this, first see the metrics using route command:

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    100    0        0 eth0         UG    600    0        0 wlan0

The interface with lower metric is preferred for Internet.

Here, eth0 has lower metric, so it will be preferred over wlan0. If you want to prefer wlan0, then lower its metric:

sudo ifmetric wlan0 50

Now, the routing table would look like:

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    50     0        0 wlan0         UG    100    0        0 eth0

Now Linux will be using wlan0 for Internet. The change will be reflected immediately.

Install a lightweight Desktop Environment#

By default, Ubuntu uses GNOME 3 and GDM3, however, they are too heavy. Many users have reported that they can save 1 GB of RAM when using a lightweight desktop environment, such as LXDE, LXQt, XFCE.

Here are some choices:


MATE is a lightweight desktop based on GNOME2 base code, it’s fully open source and a very nice option.

sudo apt install ubuntu-mate-core

Lubuntu (LXDE/LXQt)

Lubuntu is another lightweight option which I recommend if your system is low on resources or if you are giving new life to an older computer. Install it using this command:

sudo apt install lubuntu-core

Xubuntu (XFCE)

Xubuntu is an Ubuntu derivative based on the Xfce desktop environment that is light, simple, stable, but it’s also highly customizable. If you want to try it, use the following command:

sudo apt install xubuntu-core

When asked, select lightdm as the Desktop Manager, instead of gdm.

Missing packages in a minimal installation

The most happened issue is missing fbdev which shown in the log:

(WW) Warning, couldn't open module fbdev
(EE) Failed to load module "fbdev" (module does not exist, 0)
Fatal server error:
(EE) no screens found(EE)

To install fbdev, run:

sudo apt install xserver-xorg-video-fbdev

Keep the cache in RAM#

Computers with at least 12 GB of memory (RAM), will probably benefit by shrinking the cache less aggressively.

sudo gedit admin:///etc/sysctl.conf

Add below lines at the bottom of the file:

# keep the cache

Use temporary folder in RAM#

Turn on tmpfs and mount /tmp on it:

sudo cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
sudo systemctl enable tmp.mount

Disable Firewall log#

You usually don’t care about this kind of log, so let it go:

sudo ufw logging off

Disable journal feature#

Only disable journal feature on a separated disk which contains only build source code and data.

A journaling file system is a file system that keeps track of changes not yet committed to the file system. In the event of a system crash or power failure, such file systems can be brought back online more quickly with a lower likelihood of becoming corrupted.

On build server machine, system failure is rare, so you can disable this journaling feature.

Press ESC on boot, then select Advanced Boot optionrecovery mode.

In the Recovery Menu, select root to enter the command line mode.

Trigger the emergency mount, and then turn off the journal feature on the target disk:

echo "u" > /proc/sysrq-trigger
tune2fs -O ^has_journal /dev/<disk>

Verify with:

debugfs -R features /dev/<disk>

If you are disabling on a data storage, do not need to go to Recovert mode. Just unmount the disk and use above tools with sudo. E.g.:

sudo umount /dev/sda
sudo tune2fs -O ^has_journal /dev/sda

Disable access time#

Linux writes the access time every you read a file. It’s the very rare program indeed that relies on access time, so disabling access time is safe virtually everywhere.

To disable access time, add noatime into the mount option in /etc/fstab on the target device.

For example:

/dev/disk/by-uuid/<uuid> /mnt/work auto nosuid,nodev,noatime,nofail,x-gvfs-show 0 0

Remove Grub timeout#

The grub gives you 10 seconds to change between dual boot OS or to go in recovery. This time can be reduced, by entering below command to open grub configuration:

sudo gedit /etc/default/grub &

Then change GRUB_TIMEOUT=10 to GRUB_TIMEOUT=1.

And update the settings:

sudo update-grub