Ubuntu Setup

From Ever changing code
Jump to navigation Jump to search

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/mapper/ubuntu--vg-swapt_1
/dev/sda
 /dev/sda1 (50G)

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

#Boot device:
/dev/mapper/ubuntu--vg-root

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                                                    
piotr@u18:~$


$ lsblk /dev/sda --fs
NAME                  FSTYPE      LABEL UUID                                   MOUNTPOINT
sda                                                                            
└─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 \
transmission-*
sudo apt-get purge xul-ext-ubufox #Canonical FF customizations
sudo apt-get remove gnome-mahjongg gnome-mines gnome-sudoku #games
sudo apt-get remove gnome-video-effects gstreamer1.0-*
XTREME

UnInstallant Ubuntu software notifier

sudo apt-get remove update-notifier

Uninstall locales - unused languages etc

sudo apt-get install localepurge

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

Opera

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

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

Silverlight

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

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 write /org/gnome/desktop/screensaver/idle-activation-enabled false  #gnome
dconf write /org/gnome/desktop/screensaver/lock-enabled            false
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

# 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

# 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

# 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:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

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 10.0.2.2


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 10.10.11.11

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

# 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
ClipCapIt-190807-080016.PNG

References