Configuration Common Linux: Difference between revisions

From miki
Jump to navigation Jump to search
Line 66: Line 66:
:*[[Ubuntu#Medibuntu|Medibuntu]] (replaced by Videolan)
:*[[Ubuntu#Medibuntu|Medibuntu]] (replaced by Videolan)


* Update {{file|/etc/sudoers}}:
* Create new files in {{file|/etc/sudoers.d}}:
<source lang=bash>
<source lang=bash>
# envkeep
sudo visudo
echo "Defaults env_keep += \"http_proxy https_proxy GREP_OPTIONS DISPLAY XAUTHORITY HOME\"" | sudo tee /etc/sudoers.d/envkeep
</source>
# Truecrypt
<source lang=diff>
echo "ALL ALL = NOPASSWD: /usr/bin/truecrypt" | sudo tee /etc/sudoers.d/truecrypt
# See the man page for details on how to write a sudoers file.
# Privoxy - no longer needed with tun2socks-manager
#
#echo "ALL ALL = (ALL) NOPASSWD: /etc/privoxy/set-network-config" | sudo tee /etc/sudoers.d/privoxy
Defaults env_reset
# rfkill - no more used
+Defaults env_keep += "http_proxy https_proxy GREP_OPTIONS DISPLAY XAUTHORITY HOME"
#echo "ALL ALL = NOPASSWD: /sbin/rfkill" | sudo tee /etc/sudoers.d/rfkill
Defaults mail_badpass
sudo chmod o-r /etc/sudoers.d/*
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
#includedir /etc/sudoers.d
# Specific commands that do not require password
+ALL ALL = (ALL) NOPASSWD: /etc/privoxy/set-network-config
+ALL ALL = NOPASSWD: /usr/bin/truecrypt
+ALL ALL = NOPASSWD: /sbin/rfkill
</source>
</source>

* Install latest kernel [https://wiki.ubuntu.com/Kernel/LTSEnablementStack]
* Install latest kernel [https://wiki.ubuntu.com/Kernel/LTSEnablementStack]
<source lang=bash>
<source lang=bash>

Revision as of 19:25, 15 March 2019

This page details a common configuration for Linux, independent of the underlying platform.

Install script

  • Initial install script to install common applications
sudo apt-get install git etckeeper
git config --global user.email "user@server.com"                   # Make sure this is defined for admin user + root
git config --global user.name "User Name"                          # or release upgrade might fail in the future
sudo su -
git config --global user.email "user@server.com"
git config --global user.name "User Name (root)"
logout

sudo vi /etc/etckeeper/etckeeper.conf                              # Select git, avoid daily commit, avoid auto-commit
sudo etckeeper init
sudo etckeeper commit "1st commit"
cd /etc
sudo vi .gitignore                                                 # Ignore resolv.c* (and cups/subscriptions.* before Ubuntu Precise)
sudo git rm --cached resolv.c*
sudo git rm --cached cups/subscriptions.*                          # No longer needed on Ubuntu Precise and after
sudo git add .gitignore
sudo etckeeper commit "ignore resolv.c*, cups/subscriptions.*"

sudo vi /etc/apt/sources.list                                      # Enable / add all relevant repositories (partner...)
sudo etckeeper commit "enable partners, extra repositories"

sudo apt-get update
sudo apt-get install libnss-mdns avahi-daemon mdns-scan synapse gitk git-gui git-doc \
                     mc autossh ssh vim-gnome exuberant-ctags cscope ruby
                                                                   # 14.04 Trusty: package 'synapse' missing
                                                                   # -> Install from 13.10 package

sudo add-apt-repository ppa:phoerious/keepassxc
sudo apt-get update
sudo apt-get install keepassxc                                     # Upgrade: keepassx -> keepassxc

# Restore my profile
sudo vi /etc/hosts                                                 # Add host 'griffin' - make sure localhost as FQDN:
                                                                   #     127.0.1.1	myhost.domain.com
ssh griffin -C "cat /etc/hosts"                                    # recover any needed host ip address
sudo vi /etc/hosts                                                 # ... and write them
sudo etckeeper commit "update /etc/hosts file"
git clone git@apple-pi:git/home.git
mv home/.git .
rm -rf home
git reset --hard
git st
export PATH=$PATH:$HOME/bin
set-network.sh
chmod 600 .ssh/*
chmod 644 .ssh/id_rsa.pub
mkdir tmp
restoresettings
                                                             # Opera
# sudo add-apt-repository ppa:synapse-core/ppa               # Synapse - older ubuntu release
sudo add-apt-repository ppa:tualatrix/next                   # Ubuntu Tweak
                                                             # 14.04 Trusty: ppa not yet available
sudo add-apt-repository ppa:team-xbmc/ppa                    # XBMC
sudo apt-get update
These repositories are obsolote or discontinued:
  • Create new files in /etc/sudoers.d:
# envkeep
echo "Defaults       env_keep += \"http_proxy https_proxy GREP_OPTIONS DISPLAY XAUTHORITY HOME\"" | sudo tee /etc/sudoers.d/envkeep
# Truecrypt
echo "ALL         ALL = NOPASSWD: /usr/bin/truecrypt" | sudo tee /etc/sudoers.d/truecrypt
# Privoxy - no longer needed with tun2socks-manager
#echo "ALL         ALL = (ALL) NOPASSWD: /etc/privoxy/set-network-config" | sudo tee /etc/sudoers.d/privoxy
# rfkill - no more used
#echo "ALL         ALL = NOPASSWD: /sbin/rfkill" | sudo tee /etc/sudoers.d/rfkill
sudo chmod o-r /etc/sudoers.d/*
  • Install latest kernel [1]
# Get Utopic kernel
sudo apt-get install --install-recommends linux-generic-lts-utopic xserver-xorg-lts-utopic libgl1-mesa-glx-lts-utopic libegl1-mesa-drivers-lts-utopic
# Get Vivid kernel
# DO NOT UPDATE TO VIVID X.ORG - IT LEAKS LIKE HELL
# sudo apt-get install --install-recommends linux-generic-lts-vivid xserver-xorg-lts-vivid libgl1-mesa-glx-lts-vivid libegl1-mesa-drivers-lts-vivid
sudo apt-get install --install-recommends linux-generic-lts-vivid
  • Install common applications
# Common Applications
sudo apt-get install rpcbind                                              # Use 'portmap' before oneiric ocelot
sudo apt-get install cifs-utils                                           # Use 'smbfs' with precise pangolin or before

sudo apt install terminator smbclient nfs-kernel-server nfs-common \
                 autofs apt-file p7zip-full p7zip-rar dlocate thunderbird \
                 chromium-browser meld colordiff ttf-mscorefonts-installer \
                 qiv gthumb gnupg-agent renameutils wine-stable mplayer \
                 mplayer-doc mplayer-fonts gimp gdmap gparted \
                 xbmc xsel \
                 compizconfig-settings-manager moreutils tmux \
                 unity-tweak-tool libavcodec-extra57 \
                 pepperflashplugin-nonfree compiz-plugins dconf-tools \
                 gnome-tweak-tool silversearcher-ag gawk
                                                                          # Removed in Bionic: gnome-mplayer gecko-mediaplayer ubuntu-tweak 
                                                                          #     app-install-data-medibuntu
                                                                          # Upgraded: libavcodec-extra-54
                                                                          # Discontinued: ubuntu-restricted-extras 
                                                                          # 14.04 Trusty: packages 'ubuntu-tweak', 'app-install-data-medibuntu',
                                                                          # 'smbfs' missing
sudo apt-get install chrome-gnome-shell                                   # Since U18.04, to manage Gnome extension in Chrome / FF. Require browser ext.
sudo dpkg -i ripgrep_0.10.0_amd64.deb                                     # Download from https://github.com/BurntSushi/ripgrep

sudo apt-file update
sudo /usr/share/doc/libdvdread4/install-css.sh
# Optional essentials
sudo apt-get install nmap winbind libnss-winbind                          # winbind + libnss-winbind for NetBIOS name resolution
sudo vi /etc/nsswitch.conf                                                # Add "wins" at the end of "hosts:" line
# Optional applications
sudo apt-get install gnugo qgo uligo cgoban quarry pgpgpg powertop
# Optional - Fix blue video in flash (see below for details)
sudo mkdir /etc/adobe
echo -e "EnableLinuxHWVideoDecode=1\nOverrideGPUValidation=true" | sudo tee /etc/adobe/mms.cfg > /dev/null
sudo etckeeper commit "Fix blue video bug in adobe flashplayer"
  • Install fonts
mkdir ~/.fonts
wget https://github.com/belluzj/fantasque-sans/releases/download/v1.7.1/FantasqueSansMono.tar.gz
tar xvzf FantasqueSansMono.tar.gz -C ~/.fonts/ --wildcards *.ttf
sudo fc-cache -fv
  • Apply common settings (see below)
  • Applications not from repositories:
    • Panda glGo 1.4.1 (does not work on Oneiric 64-bit)
  • Install latest updates:
sudo apt-get dist-upgrade
  • Restore scrollbar behaviour in GTK3 [2], [3].
Use Shift+Click or Template:Right click to get the jump to click behaviour.
cat >> ~/.config/gtk-3.0/settings.ini <<__HERE__
[Settings]
gtk-primary-button-warps-slider=false
__HERE__
Ubuntu 12.04
sudo vi /etc/default/apport                         # Disable apport by setting "enabled=0"
sudo etckeeper commit "disable apport"

terminator

Install the new terminator that depends on GTK3 (terminator-gtk3, version 1.97~ppa3).

See Terminator.

tmux

Make sure that tmux is at least version 2.2. If not install it:

neovim / vim

See Neovim page to install Neovim.

neovim / vim plugins

Neovim / vim plugins are installed via vim-plug, which is part of the home git repository.

However the following plugins require extra configuration:

YouCompleteMe

This is the install script to enable the minimum features. Note that this is done automatically by vim-plug.

cd ~/.vim/plugged/YouCompleteMe
./install.py
cpsm

Run this script after installing the plugin with vim-plug.

sudo apt install libboost-all-dev cmake python-dev libicu-dev
cd ~/.vim/plugged/cpsm
./install.sh

fzf

fzf is a very fast fuzzy-finder written in Go.

It is installed when installing vim plugins. To install it in bash:

git clone https://github.com/junegunn/fzf.git ~/.fzf    # Skip this step if already present
cd ~/.fzf
./install

Java from Oracle

Reference: https://launchpad.net/~webupd8team/+archive/ubuntu/java

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Java 8
sudo apt install oracle-java8-set-default
Java 7
sudo apt install oracle-java7-installer
# An error occur because archive is not found anymore
# ... so we copy back our backup at the right location
sudo cp /smb/lacie-cloudbox/family/archives/software/any/oracle-jdk-7u80-linux-x64/jdk-7u80-linux-x64.tar.gz /var/cache/oracle-jdk7-installer/
# Resume install
sudo apt install oracle-java7-installer

LibreOffice

Install latest LibreOffice by adding the PPA:

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt update

KeepassXC

We now store the database on Owncloud, and sync to local git repository with cron.

Script:

#! /bin/bash

BASEDIR=$(dirname "$(readlink -nf "${BASH_SOURCE[0]}")")
cd "$BASEDIR"

KDBX=work.kdbx
OWNCLOUD_DIR=~/ownCloud/kdbx

if ! diff -q $OWNCLOUD_DIR/$KDBX $KDBX; then
    echo "Adding $KDBX to git..."
    cp $OWNCLOUD_DIR/$KDBX $KDBX
    git add $KDBX
    git commit -m "Sync keepassx db with Owncloud"
fi

Cronjob:

31 * * * *      chronic ~peetersm/private/kdbx/sync_from_owncloud.sh

Gnome tweaks

  • Top bar → Application Menu → OFF.

Gnome extensions

AlternateTab
  • By default, Gnome Alt-Tab will group windows from the same application. To get rid of this annoying behaviour and restore the good old one, install extension AlternateTab.
  • Debian: To install it, go to Gnome Tweaks (package gnome-tweaks).
  • Ubuntu: press Super key, then AlternateTab, it will be installed automatically. This might require installing sudo apt-get install gnome-tweak-tool [4].
system-monitor (github)
  • This replaces applet indicator-multiload that no longer works since Ubuntu Bionic.
  • Requires the following package: gir1.2-gtop-2.0 gir1.2-networkmanager-1.0 gir1.2-clutter-1.0
  • However the indicator conflicts with owncloud client indicator (no longer visible).
No title bar
  • Revive Unity-like merging of window title bar with desktop top bar.
  • Caveat: Window's menu is not merged [5]
Gnome Global Application Menu
  • AVOID 'ALT' KEY STEALING FOCUS → In extension configuration (via Gnome Tweaks), Go to main menu, click on Alt, then Backspace to remove the shortcut. Breathe again.
  • To merge application menu in top title bar.
  • As a side-effect, this extension fixes the owncloud-icon-not-showing bug.

Debian

  • Add contrib non-free repositories to apt source [6].
  • Add sid release apt sources.

Install these packages

sudo apt install mlocate dnsmasq-base

We install Firefox 56 and Thunderbird 52.8 to preserve some important add-ons. These packages and their dependencies are no longer available but they can still be downloaded on http://snapshot.debian.org/:

sudo dpkg -i firefox_56.0-2_amd64.deb \
    libcurl3_7.52.1-5+deb9u9_amd64.deb \
    libevent-2.0-5_2.0.21-stable-3_amd64.deb \
    libhunspell-1.3-0_1.3.4-2_amd64.deb \
    libhunspell-1.6-0_1.6.2-2_amd64.deb \
    libvpx4_1.6.1-3+deb9u1_amd64.deb \
    thunderbird_52.8.0-1~deb8u1_amd64.deb
sudo apt install -f
echo "firefox hold" | sudo dpkg --set-selections
echo "thunderbird hold" | sudo dpkg --set-selections

Wayland / XOrg

In Ubuntu 18.04 and Debian Testing (Debian 10, Buster), Wayland is enabled by default in Gnome session.

Sadly enough, Wayland comes with several regressions. To disable Wayland, edit file /etc/gdm3/daemon.conf:

-#WaylandEnable=false
+WaylandEnable=false

Common Applications

Opera (opera) See Opera to fix apt key issues
Firefox (firefox)
  • Set Ctrl-Tab to show last tab. Browse to about:config, and set browser.ctrlTab.previews to True.
Synapse (synapse)

Install with:

sudo add-apt-repository ppa:synapse-core/ppa
sudo apt-get update && sudo apt-get install synapse
  • Start synapsePreferences → click Startup on login
  • Still in preferences, set Activate shortcut to Ctrl-Alt-Space
Git (git gitk git-gui git-doc gitweb git-svn) [2011-12-15] Updated to 1.7.8 Installed from sources
etckeeper (etckeeper) Configured to use git as SCM, AVOID_DAILY_AUTOCOMMITS, AVOID_COMMIT_BEFORE_INSTALL
mDNS (libnss-mdns avahi-daemon mdns-scan) After install, do:
mdns-scan

Machine should broadcast its ip address on griffin.local to all avahi clients. For some strange reason, avahi may append a -2 suffix to broadcast name. To avoid that, edit /etc/avahi/avahi-daemon.conf and set host-name variable:

host-name=griffin
Midnight Commander (mc) See reference page. Use vi as standard viewer/editor. Installed version from mc official repository to fix file highlighting issue.
AutoSSH (autossh)
SSH (ssh)
  • Create / restore private key:
ln -sf ../private/ssh/id_rsa_work ~/.ssh/id_rsa
  • If using bin/ssh-agent-refresh.sh:
touch ~/.use_ssh_agent
Vim (vim vim-gnome exuberant-ctags) including GVim to enable support of X clipboard
Vim/Cscope (cscope)
Ruby (ruby) ... for Vim plug-in snipMate.vim
Gnome Terminator (terminator) See Gnome Terminator for tips.
  • Set background to transparent 6% (through ~/.config/terminator/config)
  • Set scrollback to infinite scrollback
  • Custom geometry terminator --geometry=1220x720+100+100 (in application menu)
  • Font Lucida Console, 9 (on nxl67002ux / nxl67063ux), or Bitstream Vera Sans Mono Roman 9 (on nxl67063 Cygwin-X).
  • (not needed on trusty) Set terminator as default terminal for Ctrl-Alt-T [7]:
gsettings set org.gnome.desktop.default-applications.terminal exec 'terminator --geometry=1220x720+100+100'
Samba (smbclient cifs-utils)
  • Use package smbfs for u1204 Precise Pangolin and before
NFS Server (nfs-kernel-server nfs-common rpcbind) See NFS for more details; Created entries in /etc/exports. rpcbind replaces portmap since Oneiric.
AutoFS (autofs)
  • Mount mnemosyne shares as NFS autofs (see [8]) and as SMB autofs
Enabled/created the following automounters in /etc/auto.master:
/net                /etc/auto.net                   --ghost
/smb/mnemosyne      /etc/auto.smb.mnemosyne         --ghost
/smb/lacie-cloudbox /etc/auto.smb.lacie-cloudbox    --ghost
  • Create configuration file /etc/auto.smb.mnemosyne
  • Create SMB credential files /etc/auto.smb.mnemosyne.* (see man mount.cifs)
  • Created path for mount points:
sudo mkdir /net
sudo mkdir -p /smb/mnemosyne
# ls /net/mnemosyne
# sudo mkdir -p /mnt/mnemosyne
# for i in /net/mnemosyne/volume1/*; do sudo ln -s $i /mnt/mnemosyne/$(basename $i); done
  • Or recover settings from an already configured host:
scp griffin:tmp/autofs.tgz .                                        # Configure autofs
sudo tar -xvzf autofs.tgz
sudo cp etc/* /etc
  • If necessary, mount shares read-only: add option ro in /etc/autofs.smb.mnemosyne
KeePassX (keepassx)
  • Set kbd layout to fix autotype bug ([9]). Create ~/.xprofile and /etc/skel/.xprofile [10]:
#!/bin/sh

#
setxkbmap be
apt-file (apt-file)
p7zip (p7zip-full p7zip-rar)
dlocate (dlocate)
Thunderbird (thunderbird) See Thunderbird.
Google Chrome (chromium-browser)
Meld (meld) Diff tool
Color Diff (colordiff)
MS Truetype core fonts (ttf-msttcorefonts-installer)
Qiv (qiv)
gThumb (gthumb)
GPG (gpgv gnupg-agent pgpgpg)
  • Added use-agent at end of ~/.gnupg/gpg.conf
  • Edit ~/.gnupg/gpg.conf as necessary.
Rename utils (renameutils)
Wine (wine) See Wine page
MPlayer (mplayer mplayer-doc mplayer-fonts)
Flash Plugin 10 (flashplugin-installer)
  • Enable Ubuntu partner repository if needed(deb http://archive.canonical.com/ubuntu lucid partner).
  • In case of error failure to download extra data files flashplugin-installer, try
sudo apt-get --reinstall install flashplugin-installer

(Old recipe:

sudo aptitude autoremove "flashplugin-*"
sudo aptitude install flashplugin-installer
)
  • broken— This is too unstable, see next solution — On Ubuntu 12.04 with NVidia card, there is a bug Flash video appears blue. That link recommends to update libvdpau1, but in my case it was already at the latest version. Instead the following did the trick (from bug 968647):
sudo mkdir /etc/adobe
echo -e "EnableLinuxHWVideoDecode=1\nOverrideGPUValidation=true" | sudo tee /etc/adobe/mms.cfg > /dev/null
  • Another solution is to disable hardware acceleration, by going into flash player settings. If the settings window is not clickable, first disable unity 3D (for instance with metacity --replace&)
Quicktime plugin (gnome-mplayer gecko-mediaplayer) To play Quicktime content in Opera, Firefox
Gimp (gimp)
Graphical Disk Map (gdmap)
gparted (gparted)
Ubuntu restricted extras (ubuntu-restricted-extras) shall install automatically libdvdread4
libdvdcss2 Installed via sudo /usr/share/doc/libdvdread4/install-css.sh (see also [11])
libavcodec-extra-54 (libavcodec-extra-54)
Ubuntu tweak (ubuntu-tweak) see Ubuntu Tweak
Medibuntu application center (app-install-data-medibuntu)
  • No longer available on u1404 Trusty Tahr
  • This install medibuntu apps in Ubuntu Application Center
XBMC (xbmc) see XBMC
XSel (xsel)
Compiz config settings manager (compizconfig-settings-manager)
moreutils For chronic, sponge
tmux (tmux) Alternative to screen, but with support for multiple panes like terminator
CPU indicator (indicator-multiload) Selected CPU, Memory, Network
Unity tweak tool (unity-tweak-tool
  • Don't show desktop in switcher
  • top right hot corner: Spread all windows

Optional Applications:

GNU Go (gnugo)
Various Go games (qgo uligo cgoban)
Quarry (quarry) Board games Go, Amazons, and Reversi
PowerTop (powertop)

Applications not from repositories:

Panda glGo 1.4.1 See local page — does not work on Oneiric 64-bit

Optional Essentials:

nmap (nmap) For use with my git prj script

Common Settings

/etc/sudoers

  • SUDO - keep environment variables:
    • http_proxy, https_proxy (to keep proxy settings for apt-get etc)
    • GREP_OPTIONS (keep grep options)
    • DISPLAY, XAUTHORITY (avoid doing xhost local:root before launching X pgm)
    • HOME (e.g. to keep git aliases and settings when using etckeeper)
    • PASSWD (e.g. to pass password via env. var to mount.cifs)
Defaults        env_reset
Defaults        env_keep += "http_proxy https_proxy GREP_OPTIONS DISPLAY XAUTHORITY HOME"
  • SUDO - Allow truecrypt and rfkill w/o password:
ALL     ALL=NOPASSWD: /usr/bin/truecrypt
ALL     ALL=NOPASSWD: /sbin/rfkill

Network

  • Samba / NFS client: Via autofs

Preferences

Users

sudo useradd -s /bin/bash -m -u 1100 marie
sudo useradd -s /bin/bash -m -u 1200 isma
sudo useradd -s /bin/bash -m -u 1300 emma
sudo passwd marie
sudo passwd isma
sudo passwd emma

X11

  • Custom keyboard mapping be:
# From my profile
sudo cp ~/etc/be /usr/share/X11/xkb/symbols/be
sudo rm /var/lib/xkb/*.xkm
setxkbmap us
setxkbmap be
gsettings get org.gnome.desktop.input-sources xkb-options
gsettings set org.gnome.desktop.input-sources xkb-options "@as ['caps:escape']"
  • Fonts — disable embedded bitmaps. See Fonts.

Miscellaneous

  • Disable apport. Set enabled=0 in /etc/default/apport
  • Edit AppArmor tunables. If home directories are not located at /home (e.g. /data/home), edit apparmor tunables. See here for details.
  • Configure the console:
dpkg-reconfigure console-setup
# utf-8 / latin1+latin5 / Terminus / 16

Workaround

  • Install custom udisks package, version 1.0.4-5ubuntu2.1fuu1, to fix unreadable DVD-RW. See udisks, or bug 635499).
sudo dpkg -i udisks_1.0.4-5ubuntu2.1fuu1_amd64.deb
  • Add the following to ~/.bash_profile and ~/.profile to Meta-key (Alt) not working and Midnight Commander displays Press any key... after each command when in tmux session [12]:
# This fix meta-key support and stop mc displaying "Press any key..." in tmux session
if [ $TERM = "screen" ]; then
    export TERM=xterm
fi
if [ -n "$TMUX" ]; then
    export COLORTERM=rxvt
fi

Fonts

Antialiasing RGBA, Hinting Slight, Text scaling factor 1.00.

Application Font Selected font
Terminator Monospace font Fantasque Sans Mono 9
Gnome Terminal Monospace font Fantasque Sans Mono 9
Unity (desktop) Default font Lucida Sans Regular 9
Unity (desktop) Document font Lucida Sans Regular 10
Unity (desktop) Monospace font Fantasque Sans Mono 10
Unity (desktop) Windows title font Lucida Sans Unicode Bold 10
Firefox Sans-serif (latin) Liberation Sans 16
Firefox Monospace (Latin) Fantasque Sans Mono 16

For firefox, fonts are inspired from Mediawiki Vector skin -- typography refresh.