Ubuntu Setup

From Ever changing code

If you are using Ubuntu for various Linux projects you will find that as it comes with pre installed with many packages. On the other hand installing just minimal version seems to be too extreme. Therefore I started maitaining a list of unnecessary packages and one liner to that removes them all. Please feel free to modify for your needs.

Default partitioning

On virtual systems schema below will be applied, eg on laptops:

#Eg. for 4G memory and 50G storage system

/dev/mapper/ubuntu--vg-root        mount_point: /
 /dev/sda1 (50G)

LVM VG ubuntu-vg, LV root    as ext4
LVM VG ubuntu-vg, LV swapt_1 as swap

#Boot device:

As a good handy practice you may create 100G virtual disk that you thin provision. Then create 2 PVs for root and swap partitions. Don't utilize all space at once but extend partitions when needed. This method eliminates adding new disks to VMs saving time and efforts.

Example LVM setup, here using 30G Physical Volume(99.9% used), 1 Volume Group and 2 Logical Volumes (root and swap).

$ sudo pvs
  PV         VG        Fmt  Attr PSize   PFree 
  /dev/sda1  ubuntu-vg lvm2 a--  <29.93g 36.00m
$ sudo vgs
  VG        #PV #LV #SN Attr   VSize   VFree 
  ubuntu-vg   1   2   0 wz--n- <29.93g 36.00m
$ sudo lvs
  LV     VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   ubuntu-vg -wi-ao----  28.94g                                                    
  swap_1 ubuntu-vg -wi-ao---- 976.00m                                                    

$ lsblk /dev/sda --fs
NAME                  FSTYPE      LABEL UUID                                   MOUNTPOINT
└─sda1                LVM2_member       rP18Kb-Q12j-wjVf-C1iV-uy42-BUJD-aWFuO7 
  ├─ubuntu--vg-root   ext4              fad04a3b-5fa3-4a03-bbd6-24a93cda1eb3   /
  └─ubuntu--vg-swap_1 swap              47cd084b-89b0-4cd5-bdb8-367238842ba1   [SWAP]

List of unnecessary packages

sudo apt-get remove libreoffice-* #Remove LibreOffice
sudo apt-get remove unity-lens-* #This package contains photos scopes which allow Unity to search for local and online photos.
sudo apt-get remove shotwell* #Photo organizer
sudo apt-get remove simple-scan #Scanner software
sudo apt-get remove empathy* #Internet messaging ~13M
sudo apt-get remove thunderbird* #Email client ~61M
sudo apt-get remove unity-scope-gdrive #Google Drive scope for Unity ~116KB
sudo apt-get remove cheese* #Cheese Webcam Booth - webcam software
sudo apt-get remove brasero* #Brasero Disc Burner ~6.5MB
sudo apt-get remove gnome-bluetooth Package to manipulate bloototh devices using Gnome desktop ~2MB
sudo apt-get remove gnome-orca Orca Screen Reader -Provide access to graphical desktop environments via synthesised speech and/or refreshable braille
sudo apt-get remove unity-webapps-common #Amazon Unity WebApp integration scripts ~133KB
sudo apt-get remove ibus-pinyin #IBus Bopomofo Preferences - ibus-pinyin is a IBus based IM engine for Chinese ~1.4MB
sudo apt-get remove apt-get remove printer-driver-foo2zjs* #Reactivate HP LaserJet 1018/1020 after reloading paper ~3.2MB

Remove unnecessary packages - one liner

Ubuntu 12, 14, 16
$ sudo apt-get remove libreoffice-* unity-lens-* shotwell* simple-scan empathy* thunderbird* unity-scope-gdrive cheese*\
brasero* gnome-bluetooth gnome-orca unity-webapps-common ibus-pinyin printer-driver-foo2zjs*

Ubuntu 18. It's recommended to choose Minimal Install, so most of packages below won't get installed.
$ sudo apt-get purge libreoffice-* unity-lens-* shotwell* simple-scan empathy* thunderbird* cheese* \
brasero* gnome-bluetooth gnome-orca ibus-pinyin printer-driver-foo2zjs* xul-ext-ubufox speech-dispatcher* \
rhythmbox* printer-driver-* mythes-en-us mobile-broadband-provider-inf* \
evolution-data-server* espeak-ng-data:amd64 bluez* ubuntu-web-launchers \
sudo apt-get purge xul-ext-ubufox                           # Canonical FF customizations for u14,16,18,20
sudo apt-get remove gnome-mahjongg gnome-mines gnome-sudoku # games, works for u14,16,18,20
sudo apt-get remove gnome-video-effects gstreamer1.0-*

UnInstallant Ubuntu software notifier

sudo apt-get remove update-notifier

Uninstall locales - unused languages etc

sudo apt-get install localepurge

Set apt-get to not install recommended and suggested packages

sudo bash -c 'cat > /etc/apt/apt.conf.d/01no-recommend << EOF
APT::Install-Recommends "0";
APT::Install-Suggests "0";

To see if apt reads this, enter this in command line (as root or regular user):

apt-config dump | grep -e Recommends -e Suggests

Install necessary packages

Adobe Flash Player

sudo apt-get install flashplugin-installer

Java JRE This will install the default verison Java for you distro plus Icedtea plugin for using Firefox with Java

sudo apt-get install default-jre icedtea-plugin

Unity Settings

sudo apt-get install unity-control-center


Add Opera repository deb stable non-free to the apt-get source list in /etc/apt/sources.list. Then import a public PGP repository key.

echo "deb stable non-free" | sudo tee -a /etc/apt/sources.list
wget -qO - | sudo apt-key add -
sudo apt-get update && sudo apt-get install opera


Pipelight has been released and we can use it for silverlight as a best alternative moonlight.

sudo apt-add-repository ppa:ehoover/compholio
sudo apt-add-repository ppa:mqchael/pipelight
sudo apt-get update
sudo apt-get install pipelight

GUI tools

  • copyQ clipboard manager
  • VisualVM

Customise Ubuntu

Fix Ubuntu Unity Dash Search for Applications and Files

sudo apt-get install unity-lens-files unity-lens-applications #log out and log back in required

Fix Ubuntu <17.10 missing Control Center

sudo apt-get install unity-control-center --no-install-recommends

Fix Ubuntu >18.04 missing System Settings

sudo apt install gnome-control-center

Remove background wallpaper

Tested on Ubuntu 14,16,18

gsettings set org.gnome.settings-daemon.plugins.background active true
gsettings set org.gnome.desktop.background draw-background false        #disable 
gsettings set org.gnome.desktop.background primary-color "#000000"      #set to black
gsettings set org.gnome.desktop.background secondary-color "#000000"    #set to black
gsettings set org.gnome.desktop.background color-shading-type "solid"   #set solid colour
gsettings set org.gnome.desktop.background picture-uri file:///dev/null #remove wallpaper, not perfect but nothing worked in U15.10
gsettings set com.canonical.unity-greeter draw-user-backgrounds false   #disable not worked

# Reset background picture to origin, U15.10
gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/warty-final-ubuntu.png 

# Sets Unity greeter background, <17.04
gsettings set com.canonical.unity-greeter background /usr/share/backgrounds/warty-final-ubuntu.png

Disable screen lock out

dconf is legacy tool to configure gnome nowadays more modern way is to use gsettings.

dconf write /org/gnome/desktop/screensaver/idle-activation-enabled false  #gnome
dconf write /org/gnome/desktop/screensaver/lock-enabled            false

# Unity - Ubuntu 14.04, 16.04
gsettings set org.gnome.desktop.session     idle-delay   0      #disable the screen blackout:(0 to disable)
gsettings set org.gnome.desktop.screensaver lock-enabled false  #disable the screen lock

# VirtualBox > Ubuntu 18.04 Disabling Xserver screen timeouts
xset s off     # Xserver s parameter sets screensaver to off
xset s noblank # prevent the display from blanking 
xset -dpms     # prevent the monitor's DPMS energy saver from kicking in

# Gnome - Ubuntu 18.04 LTS, Settings > Power > Blank screen > set to: Never
gsettings get org.gnome.desktop.lockdown    disable-lock-screen      # verify status
gsettings set org.gnome.desktop.lockdown    disable-lock-screen true # set disabled
gsettings get org.gnome.desktop.screensaver lock-enabled             # verify status
gsettings set org.gnome.desktop.screensaver lock-enabled false       # set disabled
dconf write  /org/gnome/desktop/screensaver/lock-enabled false       # set disbaled using dconf
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false # some say it's last resort :)

# Power management
gsettings set org.gnome.settings-daemon.plugins.power active true  #set gnome to be the default power management run
gsettings set org.gnome.settings-daemon.plugins.power active false #turn off power management

# last resort as it was a bud in Ubuntu 11.10 with DPMS
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
gsettings set org.gnome.desktop.session idle-delay 2400

Verify by navigating in dconf-editor to /org/gnome/desktop/screensaver/

Change number of workspaces

To get the current values:

dconf read /org/compiz/profiles/unity/plugins/core/hsize
dconf read /org/compiz/profiles/unity/plugins/core/vsize

To set new values:

dconf write /org/compiz/profiles/unity/plugins/core/hsize 2
# or
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize 4
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ vsize 4

Clenup motd messages

Ubuntu at login displays a number standard messages taking terminal space causing potential loosing context of previous operations.

Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-134-generic x86_64)

 * Documentation:
 * Management:
 * Support:

  Get cloud support with Ubuntu Advantage Cloud Guest:

1 package can be updated.
0 updates are security updates.

New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Fri Aug 31 12:11:28 2018 from

This is managed by files in /etc/update-motd.d/, so deleting them will remove clutter on a screen

ls /etc/update-motd.d/
00-header             51-cloudguest         91-release-upgrade    98-fsck-at-reboot     
10-help-text          90-updates-available  97-overlayroot        98-reboot-required 

# Ubuntu Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1022-azure x86_64)
# Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1021-aws x86_64)
sudo rm /etc/update-motd.d/{10-help-text,50-landscape-sysinfo,50-motd-news,51-cloudguest,80-livepatch,95-hwe-eol}

This cuts down to this message, Ubuntu 18.04 in AWS

Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1021-aws x86_64)

0 packages can be updated.
0 updates are security updates.

Last login: Thu Jan 31 17:09:38 2019 from

Useful setups

Call screen saver from a terminal to blank all screens

# tested on Ubuntu 18.04 with Gnome
sudo apt-get install gnome-screensaver
gnome-screensaver-command -a #controls GNOME screensaver, -a activate (blank the screen)

Create application launcher

Ubuntu 18.04
# Install the GNOME-panel toolset
sudo apt-get install --no-install-recommends gnome-panel

# Every user launcher
sudo gnome-desktop-item-edit /usr/share/applications/VisualVM.desktop --create-new

# Local user only, the filename by default is a Name-of-appication.desktop
gnome-desktop-item-edit ~/.local/share/applications --create-new
Ubuntu 19.10, 20.04

In above releases gnome-desktop-item-edit has been removed from the gnome-panel package, as an alternative .desktop files can be created manually.

vi /usr/share/applications/APPNAME.desktop
[Desktop Entry]
Keywords=<eg. sql>

It's optional but you may need to right click and set 'allow launching' with addition to set executable permissions. Usual locations of .desktop files are:

  • /usr/share/applications/
  • /var/lib/snapd/desktop/applications/ for snap applications

gnome-shell-system-monitor-applet - cpu, memory indicators

gnome-shell --version # minimum v3.26
sudo apt install gnome-shell-extensions # Ubuntu 20.04 already has this package
sudo apt install gnome-tweaks # GUI to manage gnome-extensions
sudo apt install gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0
sudo apt install gnome-shell-extension-system-monitor # after requires log out

# Never worked out howz to use this
gnome-extensions install xxx
gnome-extensions enable
gnome-extensions list

Snapd - Chromium

Recently in U19+ Chromium get installed via snapd package. This is classic installation that has limited access to only a certain directories. It happen that when working with AWS we need get access to ~/.ssh folder to get ec2 machine password. This folder is denied, but we can bind mount ~/.ssh folder into the snap container directory:

$ snap list chromium 
Name      Version        Rev   Tracking       Publisher   Notes
chromium  86.0.4240.111  1373  latest/stable  canonical✓  -

# cd to chromim $HOME dir
mkdir ~/snap/chromium/current/.ssh
sudo mount --bind ~/.ssh/ ~/snap/chromium/current/.ssh

Screen shooting

In Ubuntu 20.04 Shutter is not a part of default repositories. It can be added via PPA:

sudo add-apt-repository -y ppa:linuxuprising/shutter
sudo apt-get install shutter

Audio - set defaults

For preserving settings using GUI you can install PulseAudio Volume Control pavucontrol.

Set default output/input device. In Ubuntu PulseAudio is used to control audio devices. It contains following configuration files

/etc/pulse/ # system wide
~/.config/pulse       # user configuration

Set defaults

# List devices: modules, sinks, sources, sink-inputs, source-outputs, clients, samples, cards
# sinks - outputs, sink-inputs, sources - all input/output including RUNNING and SUSPENDED devices
$ pactl list short sources | column -t
5   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink.monitor  module-alsa-card.c  s16le  2ch  48000Hz  SUSPENDED
6   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink.monitor  module-alsa-card.c  s16le  2ch  48000Hz  RUNNING
7   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink.monitor  module-alsa-card.c  s16le  2ch  48000Hz  SUSPENDED
8   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink.monitor    module-alsa-card.c  s16le  2ch  48000Hz  SUSPENDED
9   alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__source           module-alsa-card.c  s16le  2ch  48000Hz  SUSPENDED
10  alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_6__source         module-alsa-card.c  s16le  4ch  48000Hz  SUSPENDED
15  alsa_output.usb-DisplayLink_Dell_Universal_Dock_D6000_1806021690-02.analog-stereo.monitor     module-alsa-card.c  s16le  2ch  48000Hz  SUSPENDED
17  alsa_output.usb-Plantronics_Plantronics_DA40-00.multichannel-output.monitor                   module-alsa-card.c  s16le  1ch  48000Hz  SUSPENDED
19  alsa_input.usb-Plantronics_Plantronics_DA40-00.mono-fallback                                  module-alsa-card.c  s16le  1ch  16000Hz  SUSPENDED
20  alsa_input.usb-DisplayLink_Dell_Universal_Dock_D6000_1806021690-02.iec958-stereo              module-alsa-card.c  s16le  2ch  48000Hz  RUNNING

# Set defaut output device. Tab autocompletion should work (U20.04)
pactl set-default-sink alsa_output.usb-Plantronics_Plantronics_DA40-00.multichannel-output
# Set defaut input device
pactl set-default-source alsa_input.usb-Plantronics_Plantronics_DA40-00.mono-fallback

# Test, play some audio then run. IDLE - means in use
pactl list short sources | column -t | grep -e RUNNING -e IDLE
17  alsa_output.usb-Plantronics_Plantronics_DA40-00.multichannel-output.monitor                   module-alsa-card.c  s16le  1ch  48000Hz  IDLE
19  alsa_input.usb-Plantronics_Plantronics_DA40-00.mono-fallback                                  module-alsa-card.c  s16le  1ch  16000Hz  RUNNING

Make it permanent by setting default device in PulseAudio system configuration file

# Output device
sudo sed -i "s/#\(set-default-sink\) output/\1 ${OUTPUT_DEVICE}/g" /etc/pulse/ # remove '-i' to test before apply
# Input device
sudo sed -i "s/#\(set-default-source\) input/\1 ${INPUT_DEVICE}/g" /etc/pulse/

vi /etc/pulse/ # make sure lines below are in place
### Make some devices default
set-default-sink   alsa_output.usb-Plantronics_Plantronics_DA40-00.mono-fallback
set-default-source  alsa_input.usb-Plantronics_Plantronics_DA40-00.mono-fallback

# Delete local user profile and restart system, after boot new defaults should be set
rm -r ~/.config/pulse

# After reboot, defaults should be set
cat ~/.config/pulse/*default*


PulseAudio cli

>>> help # lists all available commands

pulseaudio --check # Check if any pulseaudio instance is running. It normally prints no output, just exit code. 0 means running
pulseaudio --kill  # kill, then --start
pulseaudio -D      # start pulseaudio as a daemon
# | using /etc/pulse/daemon.conf

# Pulseaudio is a user service
systemctl --user restart pulseaudio.service
systemctl --user restart pulseaudio.socket

I have a port replicator Dell D-6000, that gets randomly disconnected causing switching audio to new connected device - means itself. As workaround commenting out lines below stops this behaviour.

vi /etc/pulse/
### Use hot-plugged devices like Bluetooth or USB automatically (LP: #1702794)
# .ifexists
# load-module module-switch-on-connect
# .endif

Input devices

Motivation is to enable horizontal scrolling in Ubuntu 20.04 using Perixx Gamig Mouse Mx2000

xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Holtek USB Gaming Mouse                 	id=11	[slave  pointer  (2)]
⎜   ↳ SYNA8007:00 06CB:CD8C Mouse             	id=14	[slave  pointer  (2)]
⎜   ↳ SYNA8007:00 06CB:CD8C Touchpad          	id=15	[slave  pointer  (2)]
⎜   ↳ TPPS/2 Elan TrackPoint                  	id=19	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=8	[slave  keyboard (3)]
    ↳ CHICONY HP Basic USB Keyboard           	id=9	[slave  keyboard (3)]
    ↳ Holtek USB Gaming Mouse                 	id=10	[slave  keyboard (3)]
    ↳ Integrated Camera: Integrated C         	id=12	[slave  keyboard (3)]
    ↳ Integrated Camera: Integrated I         	id=13	[slave  keyboard (3)]
    ↳ sof-hda-dsp Headset Jack                	id=16	[slave  keyboard (3)]
    ↳ Intel HID events                        	id=17	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=18	[slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                  	id=20	[slave  keyboard (3)]
    ↳ Holtek USB Gaming Mouse                 	id=21	[slave  keyboard (3)]

# test mouse aka Virtual core pointer
xinput test 11
motion a[0]=2023  # <- cursor moving
motion a[0]=2024 a[1]=1411 
motion a[3]=19545 # <- scroll down 
button press   5 
button release 5 

# test 'virtual core keyboard' aka additional programmable buttons
## '10' - this virtual keyboard for all buttons except the scrolling wheel
xinput test 10
key press   37
key press   38

## '21' - this is scrolling wheel buttons left/right, not scrolling itself
xinput test 21
key press   248 
key release 248
  1. List of properties of a device. We want to see 'horizontal scrolling wheel buttons'

$ xinput list-props 21 Device 'Holtek USB Gaming Mouse': Device Enabled (169): 1 Coordinate Transformation Matrix (171): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 libinput Send Events Modes Available (291): 1, 0 libinput Send Events Mode Enabled (292): 0, 0 libinput Send Events Mode Enabled Default (293): 0, 0 Device Node (294): "/dev/input/event10" Device Product ID (295): 1241, 41063