This helps me to setup my Ubuntu workstations and maybe it’s useful for you as well! I am currently using Ubuntu 16.04, but most of the stuff should also work with older/newer releases.

I used to use a config management system to do all of this, but I got tired of all the work and am now just writing the important things down into this article. Works for me.

Packages

Requirements

Some packages need to be installed first to make sure all the other commands work.

  • apt-transport-https
  • software-properties-common
sudo apt-get install apt-transport-https software-properties-common 

Package Manager Setup

I configure Ruby, Node and Python package managers to install “global” packages into my home directory so I don’t have to use “sudo” to install them.

Rubygems

Create $HOME/.gemrc with the following content to ensure installation in the user directory and to avoid generating the documentation.

install: --user-install --no-document
update: --user-install --no-document

NPM

Create $HOME/.npmrc with the following content to make sure npm modules will be installed in the user directory.

prefix=/home/<username>/.local/node_modules
progress=false

Python pip

Create $HOME/.config/pip/pip.conf with the following to only use local packages and ignore system ones.

[global]
user = true

Repositories

PPA

I am using some PPA repositories for packages which are not included in Ubuntu or where newer versions are available. Install before installing the Core packages!

sudo add-apt-repository ppa:zanchey/asciinema
sudo add-apt-repository ppa:webupd8team/java
sudo add-apt-repository ppa:webupd8team/terminix
sudo add-apt-repository ppa:git-core/ppa
sudo add-apt-repository ppa:yktooo/ppa
sudo add-apt-repository ppa:peek-developers/stable
sudo add-apt-repository ppa:jlbarriere68/noson-app
sudo add-apt-repository ppa:linuxuprising/java
sudo add-apt-repository ppa:nextcloud-devs/client

Custom

Some repositories need manual steps to set them up.

  • docker - for the latest Docker releases
  • gcloud - Google Cloud SDK
  • gpxsee - GPC log file viewer and analyzer
  • heroku - Heroku provides a CLI application
  • insomnia - Insomnia HTTP client
  • iridiumbrowser - Iridium browser
  • nodesource - the latest Node.js stable versions - make sure to check the version!
  • packagecloud - My personal package repo
  • screencloud
  • signal
  • spotify
  • sublime-text
  • syncthing
  • virtualbox
  • vscode - VS Code
  • yarn
  • zerotier
# docker
curl -fsLS "https://download.docker.com/linux/ubuntu/gpg" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" > /etc/apt/sources.list.d/docker.list'

# gcloud
curl -fsLS "https://packages.cloud.google.com/apt/doc/apt-key.gpg" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://packages.cloud.google.com/apt cloud-sdk-xenial main" > /etc/apt/sources.list.d/gcloud.list'

# gpxsee
curl -fsLS "https://download.opensuse.org/repositories/home:tumic:GPXSee/xUbuntu_16.10/Release.key" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://download.opensuse.org/repositories/home:/tumic:/GPXSee/xUbuntu_16.04/ /" > /etc/apt/sources.list.d/gpxsee.list'

# heroku
curl -fsLS "https://cli-assets.heroku.com/apt/release.key" | sudo apt-key add -
sudo sh -c 'echo "deb https://cli-assets.heroku.com/branches/stable/apt ./" > /etc/apt/sources.list.d/heroku.list'

# insomnia
curl -fsLS "https://insomnia.rest/keys/debian-public.key.asc" | sudo apt-key add -
sudo sh -c 'echo "deb https://dl.bintray.com/getinsomnia/Insomnia /" > /etc/apt/sources.list.d/insomnia.list'

# iridiumbrowser
curl -fsLS "https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main" > /etc/apt/sources.list.d/iridiumbrowser.list'

# nodesource
curl -fsLS "https://deb.nodesource.com/gpgkey/nodesource.gpg.key" | sudo apt-key add -
sudo sh -c 'echo "deb https://deb.nodesource.com/node_8.x xenial main" > /etc/apt/sources.list.d/nodesource.list'

# packagecloud
curl -fsLS "https://packagecloud.io/bernd/tools/gpgkey" | sudo apt-key add -
sudo sh -c 'echo "deb https://packagecloud.io/bernd/tools/ubuntu/ xenial main" > /etc/apt/sources.list.d/packagecloud.list'

# screencloud
curl -fsLS "https://download.opensuse.org/repositories/home:olav-st/xUbuntu_16.04/Release.key" | sudo apt-key add -
sudo sh -c 'echo "deb https://download.opensuse.org/repositories/home:/olav-st/xUbuntu_16.04/ /" > /etc/apt/sources.list.d/screencloud.list'

# signal
curl -fsLS "https://updates.signal.org/desktop/apt/keys.asc" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" > /etc/apt/sources.list.d/signal.list'

# spotify
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
sudo sh -c 'echo "deb http://repository.spotify.com stable non-free" > /etc/apt/sources.list.d/spotify.list'

# sublime-text
curl -fsLS "https://download.sublimetext.com/sublimehq-pub.gpg" | sudo apt-key add -
sudo sh -c 'echo "deb https://download.sublimetext.com/ apt/stable/" > /etc/apt/sources.list.d/sublime-text.list'

# syncthing
curl -fsLS "https://syncthing.net/release-key.txt" | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.syncthing.net/ syncthing release" > /etc/apt/sources.list.d/syncthing.list'

# virtualbox
curl -fsLS "https://www.virtualbox.org/download/oracle_vbox_2016.asc" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian xenial contrib" > /etc/apt/sources.list.d/virtualbox.list'

# vscode
curl -fsLS "https://packages.microsoft.com/keys/microsoft.asc" | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

# yarn
curl -fsLS "https://dl.yarnpkg.com/debian/pubkey.gpg" | sudo apt-key add -
sudo sh -c 'echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list'

# zerotier
curl -fsLS "https://pgp.mit.edu/pks/lookup?op=get&search=0x1657198823E52A61" | sudo apt-key add -
sudo sh -c 'echo "deb https://download.zerotier.com/debian/xenial xenial main" > /etc/apt/sources.list.d/zerotier.list'

sudo apt-get update

Core

  • apt-file
  • compizconfig-settings-manager
  • curl
  • dstat
  • ffmpeg
  • git-crypt
  • gufw
  • htop
  • indicator-multiload
  • iotop
  • ipcalc
  • jq
  • libavcodec-extra
  • keepassx
  • libsecret-tools
  • linux-generic-hwe-16.04
  • linux-tools-generic-hwe-16.04
  • lftp
  • msmtp-gnome
  • msmtp-mta
  • multitail
  • mupdf
  • mutt
  • network-manager-openvpn-gnome
  • ngrep
  • nmap
  • pass
  • passwdqc
  • psensor
  • python-pip
  • qiv
  • redshift-gtk
  • rpm
  • ruby
  • ruby-dev
  • s3cmd
  • sqlite3
  • sysstat
  • tilda
  • tmux
  • tree
  • ttf-mscorefonts-installer
  • ubuntu-restricted-extras
  • unity-tweak-tool
  • vim
  • virtualbox
  • w3m
  • zeal
sudo apt-get install apt-file compizconfig-settings-manager curl dstat ffmpeg git-crypt gufw htop indicator-multiload iotop ipcalc jq libavcodec-extra keepassx libsecret-tools linux-generic-hwe-16.04 linux-tools-generic-hwe-16.04 lftp msmtp-gnome msmtp-mta multitail mupdf mutt network-manager-openvpn-gnome ngrep nmap pass passwdqc psensor python-pip qiv redshift-gtk rpm ruby ruby-dev s3cmd sqlite3 sysstat tilda tmux tree ttf-mscorefonts-installer ubuntu-restricted-extras unity-tweak-tool vim virtualbox w3m zeal 

PPA

These are provided by the PPA repositories mentioned above.

  • asciinema
  • oracle-java8-installer
  • oracle-java8-unlimited-jce-policy
  • oracle-java8-set-default
  • oracle-java10-installer
  • git
  • indicator-sound-switcher
  • nextcloud-client-nautilus
  • noson-app
  • peek
  • tilix
sudo apt-get install asciinema oracle-java8-installer oracle-java8-unlimited-jce-policy oracle-java8-set-default oracle-java10-installer git indicator-sound-switcher nextcloud-client-nautilus noson-app peek tilix 

Custom

These are provided by the custom repositories mentioned above.

sudo apt-get install code dep desk devd docker-ce git-radar glide godeb google-cloud-sdk gpxsee gron heroku hub hugo insomnia iridium-browser jid nodejs noti offlineimap portecle restic screencloud signal-desktop snzip spotify-client sublime-text syncthing virtualbox-5.2 yarn zerotier-one 

Rubygems

These are installed via rubygems.

  • bundler
  • dnsimple
  • ghi
  • gist
  • tmuxinator
  • travis
gem install --no-document bundler dnsimple ghi gist tmuxinator travis 

Python Pip

These are installed via pip.

  • glances
  • httpie
  • pinboard
  • proselint
pip install --user glances httpie pinboard proselint 

Uninstall

sudo apt-get purge nano linux-generic linux-image-generic
dpkg -l 'linux-*-4.4.0*' | grep '^ii' | awk '{print $2}' | xargs sudo apt-get -y purge

Manual

Some packages are not available in package repositories.

Chrome

Sublime Text

See custom package repositories above on how to install sublime-text.

Packages

Vagrant

The Vagrant debian package can be downloaded from the downloads page. Take the latest version.

JetBrains Toolbox App

The Toolbox app helps with installing JetBrains products.

It also offers a Chrome extension that makes it possible to open GitHub projects in IntelliJ without having to clone it manually.

youtube-dl

There are frequent releases and the binary can update itself, just download the latest version from the homepage.

mkdir -p ~/local/bin
curl -fsSL -o ~/local/bin/youtube-dl https://yt-dl.org/downloads/latest/youtube-dl
chmod +x ~/local/bin/youtube-dl

ngrok

Also a self-updating binary, just download the latest version from the homepage.

Chef Development Kit

There is no repo, download the latest version from the homepage.

draw.io

Electron based drawing tool with Bootstrap mockup support.

Settings & Configuration

System Settings

  • Appearance
    • Behavior
    • Auto-hide the Launcher: ON
    • Enable workspaces: true
    • Show the menus for a window: In the window’s title bar
  • Brightness & Lock
    • Turn screen off when inactive for: 30 Minutes
  • Language Support
    • Install “German” language in addition to the others
  • Security & Privacy

    • Diagnostics
    • Send error reports to Canonical: false
    • Send occasional system information to Canonical: false
  • Displays

    • Scale for menu and title bars: 1.12
  • Keyboard - Typing

    • Repeat Keys
    • Delay: set to 12.5%
    • Speed: set to 89.9%
  • Keyboard - Shortcuts

    • Launchers
    • Key to show the HUD: disabled
    • Launch terminal: Ctrl+Alt+Return
    • Navigation
    • Move window to workspace 1: disabled
    • Switch to workspace 1-9: Alt+1 … Alt+9
    • Windows
    • Maximize window: Ctrl+Super+M
  • Power

    • When power is critically low: Power off
    • When lid is closed: Do nothing (for both)
  • Software & Updates

    • Updates
    • Automatically check for updates: Daily
    • When there are security updates: Display immediately
    • When there are other updates: Display immediately
  • Time & Date

    • Clock
    • Show a clock in the menu bar: true
    • In the clock, show:
      • Weekday: true
      • Date and month: true
      • Year: false
      • 24-hour time: true
    • In the clock’s menu, show:
      • Monthly calendar: true
      • Include week numbers: true
      • Time in other locations:
      • Portland
      • San Francisco
      • Austin
      • Houston
      • UTC
      • Tokyo

Unity Tweak Tool

  • Unity
    • Switcher
    • Display “Show Desktop” icon: false
    • Web Apps
    • Preauthorized domains
      • Amazon: false
      • Ubuntu One: false
  • Window Manager
    • Workspace Settings
    • Workspace switcher: ON
    • Horizontal workspaces: 9
    • Vertical workspaces: 1
    • Window snapping Top Left Corner - Maximize - Top Right Corner Left Half - - Right Half Bottom Left Corner - Do nothing - Bottom Right Corner
    • Hotcorners
    • General
      • Hotcorners: ON
    • Behavior Disabled - Disabled - Disabled Disabled - - Disabled Spread all Windows - Disabled - Disabled
  • System
    • Scrolling
    • Scrollbars
      • Overlay or Legacy - Overlay seems to be okay in 16.04

CompizConfig Settings Manager

  • Desktop
    • Desktop Wall
    • Viewport switching
      • Wall Sliding Duration: 0.0000
    • Ubuntu Unity Plugin
    • Decorations
      • Override Theme Settings: true
      • Disable shadow

Locale

Replace all de_DE.UTF-8 with en_US.UTF-8 in /etc/default/locale and run update-locale.

Sudo

<username> ALL=(ALL:ALL) NOPASSWD: ALL

Emacs key bindings

gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"

Change GNOME default terminal

gsettings get org.gnome.desktop.default-applications.terminal exec
gsettings set org.gnome.desktop.default-applications.terminal exec 'tilix'

# or

sudo update-alternatives --config x-terminal-emulator

Configure Terminator (DEPRECATED)

[global_config]
  focus = mouse
  handle_size = 2
  inactive_color_offset = 1.0
[keybindings]
  help = None
  next_tab = None
  prev_tab = None
[layouts]
  [[default]]
    [[[child1]]]
      parent = window0
      type = Terminal
    [[[window0]]]
      parent = ""
      type = Window
[plugins]
[profiles]
  [[default]]
    background_image = None
    cursor_color = "#ff003c"
    custom_command = TERM=xterm-256color bash -l
    font = Monospace 12
    login_shell = True
    scroll_on_output = False
    scrollback_lines = 50000
    scrollbar_position = hidden
    show_titlebar = False
    use_custom_command = True
    use_system_font = False

Change GNOME screenshot default location

gsettings set org.gnome.gnome-screenshot auto-save-directory "file:///home/$USER/Desktop/"

Shell profile

The following snipped should be appended to $HOME/.profile.

# Custom shell init code
umask 022

extra_paths="$extra_paths $HOME/local/bin"
extra_paths="$extra_paths $HOME/.local/bin"
extra_paths="$extra_paths $HOME/.gem/ruby/2.3.0/bin"
extra_paths="$extra_paths $HOME/.local/node_modules/.bin"

for path in $extra_paths; do
    if [ -d "$path" ]; then
        PATH="$path:$PATH"
    fi
done

# Include custom bash completion config
if [ -d $HOME/.bash_completion.d ]; then
        for file in $HOME/.bash_completion.d/*; do
                . $file
        done
fi

case "$TERM" in
xterm*)
        TERM=xterm-256color
        ;;
esac

Chrome

Settings

Update browser settings on chrome://flags:

Plugins

Set GNOME text editor to Sublime

sudo update-alternatives --install /usr/bin/gnome-text-editor gnome-text-editor /usr/bin/subl 60
sudo update-alternatives --config gnome-text-editor

Extend .local/share/applications/mimeapps.list with some of the following entries.


application/ecmascript=sublime_text.desktop;
application/javascript=sublime_text.desktop;
application/mathematica=sublime_text.desktop;
application/mathml+xml=sublime_text.desktop;
application/sql=sublime_text.desktop;
application/x-ccmx=sublime_text.desktop;
application/x-chess-pgn=sublime_text.desktop;
application/x-ica=sublime_text.desktop;
application/xml-dtd=sublime_text.desktop;
application/x-perl=sublime_text.desktop;
message/news=sublime_text.desktop;
message/partial=sublime_text.desktop;
message/rfc822=sublime_text.desktop;
model/vrml=sublime_text.desktop;
text/cache-manifest=sublime_text.desktop;
text/css=sublime_text.desktop;
text/enriched=sublime_text.desktop;
text/htmlh=sublime_text.desktop;
text/html=sublime_text.desktop;
text/mathml=sublime_text.desktop;
text/plain=sublime_text.desktop;
text/rfc822-headers=sublime_text.desktop;
text/troff=sublime_text.desktop;
text/x-adasrc=sublime_text.desktop;
text/x-c++hdr=sublime_text.desktop;
text/x-chdr=sublime_text.desktop;
text/x-cmake=sublime_text.desktop;
text/x-copying=sublime_text.desktop;
text/x-csharp=sublime_text.desktop;
text/x-c++src=sublime_text.desktop;
text/x-csrc=sublime_text.desktop;
text/x-dcl=sublime_text.desktop;
text/x-dsl=sublime_text.desktop;
text/x-dsrc=sublime_text.desktop;
text/x-dtd=sublime_text.desktop;
text/x-eiffel=sublime_text.desktop;
text/x-emacs-lisp=sublime_text.desktop;
text/x-erlang=sublime_text.desktop;
text/x-fortran=sublime_text.desktop;
text/x-gettext-translation=sublime_text.desktop;
text/x-gettext-translation-template=sublime_text.desktop;
text/x-haskell=sublime_text.desktop;
text/x-idl=sublime_text.desktop;
text/x-install=sublime_text.desktop;
text/x-iptables=sublime_text.desktop;
text/x-java=sublime_text.desktop;
text/x-ldif=sublime_text.desktop;
text/x-lilypond=sublime_text.desktop;
text/x-literate-haskell=sublime_text.desktop;
text/x-log=sublime_text.desktop;
text/x-lua=sublime_text.desktop;
text/x-makefile=sublime_text.desktop;
text/x-markdown=sublime_text.desktop;
text/x-matlab=sublime_text.desktop;
text/xmcd=sublime_text.desktop;
text/x-microdvd=sublime_text.desktop;
text/x-moc=sublime_text.desktop;
text/x-modelica=sublime_text.desktop;
text/x-mof=sublime_text.desktop;
text/x-mpsub=sublime_text.desktop;
text/x-ms-regedit=sublime_text.desktop;
text/x-mup=sublime_text.desktop;
text/x-nfo=sublime_text.desktop;
text/x-objcsrc=sublime_text.desktop;
text/x-ocl=sublime_text.desktop;
text/x-ooc=sublime_text.desktop;
text/x-pascal=sublime_text.desktop;
text/x-patch=sublime_text.desktop;
text/x-python=sublime_text.desktop;
text/x-readme=sublime_text.desktop;
text/x-reject=sublime_text.desktop;
text/x-rpm-spec=sublime_text.desktop;
text/x-scala=sublime_text.desktop;
text/x-scheme=sublime_text.desktop;
text/x-setext=sublime_text.desktop;
text/x-sql=sublime_text.desktop;
text/x-ssa=sublime_text.desktop;
text/x-subviewer=sublime_text.desktop;
text/x-svhdr=sublime_text.desktop;
text/x-svsrc=sublime_text.desktop;
text/x-tcl=sublime_text.desktop;
text/x-texinfo=sublime_text.desktop;
text/x-tex=sublime_text.desktop;
text/x-troff-me=sublime_text.desktop;
text/x-troff-mm=sublime_text.desktop;
text/x-troff-ms=sublime_text.desktop;
text/x-txt2tags=sublime_text.desktop;
text/x-uil=sublime_text.desktop;
text/x-uuencode=sublime_text.desktop;
text/x-vala=sublime_text.desktop;
text/x-verilog=sublime_text.desktop;
text/x-vhdl=sublime_text.desktop;

Disable some startup programs

Make autostarted apps visible:

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

Start the “Startup Applications” app and disable everything you don’t want.

Swappiness

The Linux kernel likes to swap even though there is lots of memory available.

sudo sh -c 'echo vm.swappiness = 1 > /etc/sysctl.d/99-swappiness.conf'

Inotify watches

Some applications like IntelliJ need more user watches for inotify than the default.

sudo sh -c 'echo fs.inotify.max_user_watches = 524288 > /etc/sysctl.d/99-inotify.conf'

Golang

I like to install applications via go get into a special GOPATH so they don’t pollute my development GOPATH.

Add the following script to $HOME/bin/goget.

#!/bin/bash

export GOPATH="$LOCALGOPATH"

exec go get "$@"

Make sure the LOCALGOPATH variable is set in .profile and the PATH includes the bin/ directory of the LOCALGOPATH.

Ensure working Solarized colors in terminal

TERM needs to be xterm-256color for solarized colors to work

case "$TERM" in
xterm*)
        TERM=xterm-256color
        ;;
esac

Troubleshooting

Laptop does not suspend properly with USB HDD attached

The following might help. The XHCI and EHC* devices are enabled.

cat /proc/acpi/wakeup
Device	S-state	  Status   Sysfs node
LID	  S4	*enabled   platform:PNP0C0D:00
SLPB	  S3	*enabled   platform:PNP0C0E:00
IGBE	  S4	*enabled   pci:0000:00:19.0
EXP3	  S4	*disabled  pci:0000:00:1c.2
XHCI	  S3	*enabled   pci:0000:00:14.0
EHC1	  S3	*enabled   pci:0000:00:1d.0
EHC2	  S3	*enabled   pci:0000:00:1a.0
HDEF	  S4	*disabled  pci:0000:00:1b.0

To disable them, just echo their names into /proc/acpi/wakeup.

echo XHCI > /proc/acpi/wakeup
echo EHC1 > /proc/acpi/wakeup
echo EHC2 > /proc/acpi/wakeup

Make SSH Key Work

gnome-keyring requires the id_rsa file to have theProc-Type and DEK-Info in it. Otherwise the ssh agent does not work. A key missing this information can be converted by executing ssh-keygen -t to change the passphrase.

If the gnome-keyring stuff should be disabled:

http://dtek.net/blog/how-stop-gnome-keyring-clobbering-opensshs-ssh-agent-ubuntu-1204

GNOME Keyring Issue

There was/is an issue related to gnome-keyring and dbus-user-session which breaks or slows down apps like Chrome and gpg. The dbus-user-session package might be pulled in via the flatpack package.

If Chrome starts very slow and all your sessions are gone, this is probably it.

Solution: dpkg -P dbus-user-session

IntelliJ IDEA

There used to be a problem with IntelliJ and I-Bus where I had to restart the ibus daemon from time to time to fix the cursor in the IDE again. I didn’t see it lately but I am keeping the link here if it ever happens again.

https://youtrack.jetbrains.com/issue/IDEA-78860

NetworkManager VPN DNS Issue

When connecting to a VPN, NetworkManager does not take the pushed DNS settings into account and continues to use the local dnsmasq server. This leads to non-working DNS.

Comment the dns=dnsmasq line in /etc/NetworkManager/NetworkManager.conf file to fix it.

UEFI Restore Menu Item

If the “ubuntu” menu item is gone from the UEFI boot manager, it can be restored with the following command.

sudo grub-install --bootloader-id ubuntu /dev/sda

This might happen after enabling/disabling the Secure Boot option.

See also: https://www.thomas-krenn.com/de/wiki/Ubuntu_UEFI_Booteintr%C3%A4ge_nach_BIOS/Grub_Update_wiederherstellen

rEFInd Boot Manager

Useful to find EFI boot partition if the “ubuntu” entry is gone from the UEFI boot manager.

Panel and Sidebar disappear

$ rm .config/dconf/user

Guides

Some more or less useful links that provide some tips and guides for Ubuntu or Linux in general.

Thinkpad BIOS Update

Download the bootable ISO image from the Lenovo site.

Extract the BIOS image from the ISO file and put it onto a USB thumb drive. (sdb in this case)

sudo apt-get install genisoimage
geteltorito -o gjuj23us.img gjuj23us.iso
sudo dd if=gjuj23us.img of=/dev/sdb bs=512K

After that, the USB drive can be booted.