Jan 15, 2015 Tag: Ubuntu

Looking for wisdom about Ubuntu

Ongoing attempt to collect clever stuff about Ubuntu. Will be updated as needed.

Updated on Nov 21, 2018

Overview

Moving to a fresh install of Bionic Beaver 18.04

What to do

Videos and readings

Promising

Aliases for the shell

For example:

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

alias dco=docker-compose
alias grepalias="alias | ag"
alias mm=./mainmenu.sh
alias myhelp="cat ~/.myhelp"
alias myhelpedit="gedit ~/.myhelp &"
alias myopen="gnome-open"
alias pass="export EDITOR=joe && pass"

# use sublime and make it wait until the file has been close by sublime
alias pass='export EDITOR="subl -w" && pass'

alias ssh-hosts='cat ~/.ssh/config | grep -e "^Host" | sort'

Anacron

  • Read (de): https://dr-luthardt.de/linux.htm?tip=anacron

  • Add to /etc/anacrontab:

    # added by marble
    @daily  0  create-etc-list-of-installed-packages  dpkg -l | grep ^ii | awk '{print $2;}' >/etc/list-of-installed-packages.anacron.txt
    

dconf

deactivate ‘caps lock’

https://kofler.info/desktop-konfiguration-fuer-ubuntu-18-04/

CapsLock deaktivieren

Die überflüssigste Taste jeder Tastatur ist CapsLock. Immer wieder führt ein unbeabsichtigtes Drücken zur eINGABE FEHLERHAFTEN tEXTS. Abhilfe: Im Programm Optimierungen (also Gnome Tweaks) gibt es im Dialogblatt Tastatur und Maus den merkwürdig beschrifteten Button Zusätzliche Belegungsoptionen. Er führt in einen Dialog, in dem Sie die Funktionen diverse Spezialtasten (Strg, Alt, Windows, CapsLock) verändern können. Dort gibt es auch die Möglichkeit, CapsLock ganz zu deaktivieren

Dbeaver

Database management tool

exiftool

Commandline tool, needed for Sphinx and mblessblog:

sudo apt install libimage-exiftool-perl

FreeFileSync

Install via Ubuntu software.

Install

sudo apt install etckeeper ghex git joe ncdu qrencode silversearcher-ag sshfs xclip zsh

For .password-store, pass: qrencode, xclip

Install - What packages do I have installed?

dockrun_t3rdf

Add the following to ~/.zshrc:

if ((0)) && [[ -e ~/.docker-shell-commands.sh ]]; then true
  rm ~/.docker-shell-commands.sh
fi
if ((1)) && [[ ! -e ~/.docker-shell-commands.sh ]]; then true
  echo docker pull t3docs/render-documentation
  docker pull t3docs/render-documentation
fi
if ((1)) && [[ ! -e ~/.docker-shell-commands.sh ]]; then true
  echo GENERATE docker run --rm t3docs/render-documentation → ~/.docker-shell-commands.sh
  docker run --rm t3docs/render-documentation  show-shell-commands >~/.docker-shell-commands.sh
fi
if [[ -e ~/.docker-shell-commands.sh ]]; then true
  source ~/.docker-shell-commands.sh
fi

Flatpak

See what you can get: https://flathub.org/home

Fedora flatpak support:

sudo apt install gnome-software-plugin-flatpak
sudo add-apt-repository ppa:alexlarsson/flatpak
sudo apt update
sudo apt install flatpak

Use flatpak:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub cc.arduino.arduinoide

GnuPG, gpg-agent

Increase password cache-time

Search
Create ~/.gnupg/gpg-agent.conf
➜  ~ cat /home/marble/.gnupg/gpg-agent.conf

###+++--- GPGConf ---+++###
default-cache-ttl 28800
max-cache-ttl 288000
###+++--- GPGConf ---+++### Mi 27 Mai 2015 08:35:06 CEST
# GPGConf edited this configuration file.
# It will disable options before this marked block, but it will
# never change anything below these lines.
➜  ~
Restart gpg-agent

Usually you should not do this. But since we changed the config, let’s kill a running instance and wait until gpg-agents restarts automatically when needed with the new configuration:

gpgconf --kill gpg-agent

Gvim

  • Use the softwarecenter
  • or: sudo apt-get install vim-gtk3

Jetbrains: PhpStorm, PyCharm

Integrate Sublime Text 3

  1. Add Tool: Settings → Tools → External Tools

    Name: Sublime
    Group: External Editors
    Program: /usr/bin/subl
    Arguments: $FilePath$
    Working directory: $ProjectFileDir$
    Check: “Synchronize files after execution”
  2. Add Keyboard shortcut:

    Settings → Keymap → External Tools → External Editors → Sublime:

    Add: Strg+Alt+X

LAMP installation

apt install graphicsmagick
apt install imagemagick

Run PHP as module

# create new group htdocs
sudo groupadd htdocs
# add group 'htdocs' to user 'marble'
sudo usermod -a -G htdocs marble
# add group 'htdocs' to user 'www-data'
sudo usermod -a -G htdocs marble www-data
# logout and login again for memberships to take effect

# set user and group everywhere in 'htdocs'
sudo chown -R marble:htdocs /home/marble/htdocs
# make everything group writable
chmod -R g+w /home/marble/htdocs
# set group s bit for directories
find /home/marble/htdocs -type d -exec chmod g+s {} \;

# set umask for user
umask 002
echo "umask 002" >> ~/.zshrc

With etckeeper you may want to do:

sudo etckeeper vcs status
sudo etckeeper vcs commit "..."

Make Apache2 run with umask 002: https://serverfault.com/questions/383734/how-do-i-set-default-umask-in-apache-on-debian

To have the new umask running, check if the file /etc/apache2/envvars will be used within your Apache start file /etc/init.d/apache2:

PIDFILE=$(. /etc/apache2/envvars && echo $APACHE_PID_FILE)

Set your umask in /etc/apache2/envvars:

# umask 002 to create files with 0664 and folders with 0775
umask 002

Restart Apache2:

# pick on line of these:
sudo systemctl restart apache2
sudo systemctl restart apache2.service
sudo /etc/init.d/apache2 restart
sudo /usr/sbin/apachectl restart
# earlier
sudo service apache2 restart

Run a simple test PHP script:

<?php
if ($fp = fopen(time() . '.txt', 'w')) {
   fwrite($fp, 'This is a simple test.');
   fclose($fp);
   echo "done";
} else {
   echo "error - cannot create file";
}
?>

Check the difference:

ls -l *.txt
-rw-r--r--  1 www-data htdocs    22 Nov  9 13:24 1541766246.txt
-rw-rw-r--  1 www-data htdocs    22 Nov  9 13:24 1541766276.txt

libcanberra-gtk-module

When starting sublimetext there was an endless list of Failed to load module "canberra-gtk-module" errors on the console. To fix this:

sudo apt install libcanberra-gtk-module

MySQL

Problem
Damn, Ubuntu 18.04 Bionic Beaver uses MySQL 5.7.24. A TYPO3 installation is running on a remote server with MySQL 5.0.12. Due to differences in the php-mode settings the local copy of the installation throws errors, mainly due to zero dates in the table configurations, for example datetime values with default ‘0000-00-00 00:00:00’.
Solution
  1. Find MySQL configuration file /etc/mysql/mysql.conf.d/mysqld.cnf

  2. Add:

    [mysqld]
    character-set-server=utf8
    collation-server=utf8_general_ci
    # default for 5.7.24 and >=5.7.8 is:
    # sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    # https://www.sitepoint.com/quick-tip-how-to-permanently-change-sql-mode-in-mysql/
    # TYPO3 for example complains:
    #    #1247602160: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
    #    'database.tx_extkey_domain_model_sample.uid' which is not functionally dependent on columns in
    #    GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (More information)
    sql-mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    # then continue with the regular:
    
    # * Basic Settings
    #
    user     = mysql
    pid-file = /var/run/mysqld/mysqld.pid
    socket   = /var/run/mysqld/mysqld.sock
    # and so on …
    
  3. Restart MySQL:

    sudo systemctl restart mysql
    

Must have

YouTube OCAjv6DCJBQ

  • sudo apt install htop
  • sudo apt install terminator
  • disks # is installed by default
  • Ubuntu software: grsync, a graphical frontend for rsync
  • bleachbit?git

Overcome errors

Not enough file watches

Inotify Watches Limit: Read https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit

For an intelligent IDE, it is essential to be in the know about any external changes in files it is working with - e.g. changes made by VCS, or build tools, or code generators etc. For that reason, IntelliJ platform spins background process to monitor such changes. The method it uses is platform-specific, and on Linux, it is the Inotify facility.

Inotify requires a “watch handle” to be set for each directory in the project. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects, and reaching the limit will force IntelliJ platform to fall back to recursive scans of directory trees.

To prevent this situation it is recommended to increase the watches limit (to, say, 512K):

  1. Add the following line to either /etc/sysctl.conf file or a new *.conf file (e.g. idea.conf) under /etc/sysctl.d/ directory:

    fs.inotify.max_user_watches = 524288
    
  2. Then run this command to apply the change:

    sudo sysctl -p --system
    

    And don’t forget to restart your IDE.

    Note: the watches limit is per-account setting. If there are other programs running under the same account which also uses Inotify the limit should be raised high enough to suit needs of all of them.

No space left on device

Same as Not enough file watches.

Error
Failed to add /run/systemd/ask-password to directory watch: No space left on device
Solution
https://askubuntu.com/questions/828779/failed-to-add-run-systemd-ask-password-to-directory-watch-no-space-left-on-dev
Essence
  • “To see what’s consuming inotify watches, use lsof:”

    sudo lsof -K | grep inotify | (less||more||pg)
    
  • “The immediate fix is to run:”

    sudo -i
    echo 1048576 > /proc/sys/fs/inotify/max_user_watches
    exit
    
  • “The long-term fix is to edit the file /etc/sysctl.conf to include the line:”

    fs.inotify.max_user_watches=1048576
    

Pinta

PHP

php.ini

Old ‘brutal’ php.ini settings for a local dev purpose:

[Date]
date.timezone = 'Europe/Berlin'
[PHP]
display_errors = 'On'
display_startup_errors = 'On'
expose_php = 'On'
max_execution_time = '86400'
max_file_uploads = '20'
max_input_time = '600'
max_input_vars = '1500'
memory_limit = '2560M'
post_max_size = '50M'
upload_max_filesize = '50M'
[Pcre]
pcre.backtrack_limit = '1000000'
pcre.recursion_limit = '1000000'
[SQL]
sql.safe_mode = 'Off'
[mail function]
mail.add_x_header = 'On'
[xdebug]
xdebug.max_nesting_level=400
xdebug.remote_enable=1

Shutter as screenshot tool

Skype

Using: “Ubuntu-Software”, search for ‘skype’, install entry of dl.flathub.org

Snap

snap list
snap df
snap interfaces
snap search arduino
# snap remove arduino-mhall119
# ! use '--classic', otherwise the app has no rights to access /dev/ttyUSB0
snap install arduino-mhall119 --classic
snap refresh

Sublime Text 3

https://www.sublimetext.com/ A sophisticated text editor for code, markup and prose

Install for Linux

Follow the ‘apt’ method for Ubuntu/Debian: https://www.sublimetext.com/docs/3/linux_repositories.html

Choose the ‘dev’ sources.

# Install the GPG key:
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | \
     sudo apt-key add -

## Ensure apt is set up to work with https sources:
## ((was not necessary for 18.04))
## sudo apt-get install apt-transport-https

## Stable
# echo "deb https://download.sublimetext.com/ apt/stable/" | \
        sudo tee /etc/apt/sources.list.d/sublime-text.list

# Dev
echo "deb https://download.sublimetext.com/ apt/dev/" | \
      sudo tee /etc/apt/sources.list.d/sublime-text.list

# Update apt sources and install Sublime Text
sudo apt update
sudo apt install sublime-text

Transfer Settings from old machine

Search the internet for “sublime copy settings”. Answer: Sync folder /home/marble/.config/sublime-text-3/Packages/User.

Teamviewer

Use sshfs to mount files of previous machine

# Ubuntu Bionic Beaver 18.04
sudo apt update
sudo apt install sshfs
sudo /mnt/t203
# mount
sudo sshfs -o allow_other,IdentityFile=/home/marble/.ssh/id_rsa marble@192.168.1.203:/home/marble /mnt/t203
# unmount
sudo umount /mnt/t203

oh-my-zsh

  1. Install zsh: sudo apt install zsh

  2. Read: https://github.com/robbyrussell/oh-my-zsh

  3. Run non-sudo:

    sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
    
  4. Edit ~/.zshrc. Make sure at least ‘git’ and ‘pass’ are in the list of plugins:

    # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
    # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
    # Example format: plugins=(rails git textmate ruby lighthouse)
    # Add wisely, as too many plugins slow down shell startup.
    plugins=(git history jump pass z)
    

Webcam

Internal Lenovo T570 webcam

https://help.ubuntu.com/community/Webcam

Test:

vlc v4l2:///dev/video0  # ir camera
vlc v4l2:///dev/video1  # normal camera

cheese  # ir camera
cheese -d /dev/video1   # normal camera - but shows ir camera

https://askubuntu.com/questions/1062331/intergrated-webcam-not-working-after-upgrade-to-18-04

sudo apt install ffmpeg # installed. Do we need it?
sudo apt install mplayer
# do a test (this worked):
mplayer -cache 128 -tv driver=v4l2:width=640:height=480:device=/dev/video1 -vo xv tv://
dmesg | grep uvc

Conclusion: Ubuntu 18.04 Bionic Beaver did recognize the cameras out of the box. Nothing extra had to be done. /dev/video0 is the infrared camera, /dev/video1 is the normal camera. Just make sure you select the correct camera in an application like Slack.

Youtrack

Installation

  • Youtrack Jetbrains installation and upgrade

    Prerequisites

    To perform this installation, verify that the following prerequisites are met:

    You have installed Oracle Java SE Runtime Environment 8 or later. The instructions here require that the JRE is available from the path /usr/bin/java. Any external hostname (proxy hostname) is resolvable from the actual host where YouTrack is installed.

  • https://linuxconfig.org/how-to-install-java-on-ubuntu-18-04-bionic-beaver-linux

    Install Java v11:

    # install java v11
    sudo add-apt-repository ppa:linuxuprising/java
    sudo apt update
    sudo synaptic
    sudo apt install oracle-java11-installer
    ➜  ~ java -version
    java version "11.0.1" 2018-10-16 LTS
    Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
    Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
    

    This installation of Java v11 works, but some Youtrack versions required an older Java. So let’s completely uninstall Java v11 and install Java v8 which does the job for Youtrack versions 6.5, 7, 2017.1, 2018.1, 2018.3 (= latest at the moment):

    # Install Java v8
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt update
    sudo synaptic
    sudo apt install oracle-java11-installer
    ➜  ~ java -version
    java version "1.8.0_191"
    Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
    

How to copy the installation and upgrade to latest

New machine:

  1. Install Java v8

  2. We are using the ‘jar’-type installation and upgrading from 6.5

  3. Download Youtrack JAR files for versions 7, 2017.1, 2018.1, 2018.3 (latest)

  4. Create user ‘youtrack’

  5. Copy OLD MACHINE /home/youtrack/teamsysdata to NEW MACHINE /home/youtrack/teamsysdata to

  6. Upgrade step by step:

    New machine:

    • java -jar /home/youtrack/youtrack-7.jar 0.0.0.0:8112
    • java -jar /home/youtrack/youtrack-2017-1.jar 0.0.0.0:8112
    • java -jar /home/youtrack/youtrack-2018-1.jar 0.0.0.0:8112
    • java -jar /home/youtrack/youtrack-2018-3.jar 0.0.0.0:8112

Run as a service

  • Install YouTrack JAR as service

    1. Create a systemd service file in the following directory: /etc/systemd/system/youtrack.service. Paste the following content into the youtrack.service file:

      [Unit]
      Description=Youtrack
      Requires=network.target
      After=syslog.target network.target
      
      [Service]
      Type=simple
      WorkingDirectory=/home/youtrack
      # ExecStart=/usr/bin/java -jar /home/youtrack/youtrack.jar --J-Xmx1G 8080
      ExecStart=/usr/bin/java -jar /home/youtrack/youtrack.jar --J-Xmx1G 0.0.0.0:8112
      User=youtrack
      
      [Install]
      WantedBy=default.target
      

      Customize the content of the file as needed: If you want YouTrack to start on a different port number, edit the default port 8080. Add and modify other Java parameters as needed.

      Use the following command to reload the systemd daemon and enable the YouTrack service on system start:

      systemctl daemon-reload
      systemctl enable youtrack.service
      

      Enter the following command to run the YouTrack service:

      service youtrack start
      

      Open http://<your-host-name>:8112 in a web browser and wait for the application to become available. As it takes some time to start the application, the port may be unreachable for a short while.

  • We are running YouTrack on 0.0.0.0 and port 8112. This makes YouTrack available in our local network as youtrack.local.mbless.de:8112.

    Important: In the firewall open port 8112 on the new machine for incoming requests.

  • Run netstat -tapn to verify that YouTrack is available.

Common tasks

SSH

Remove identity from key keeper

ssh-add -D   # Delete all identities (from key keeper)
ssh-add -D   # Delete identity       (from key keeper)
ssh-add -l   # List fingerprints of all identities
ssh-add --help
ssh-add -t 3600  # set lifetime for already stored keys to 1 hour

Issues

Keyboard entry

Keywords: unicode, kbd, keyboard, compose, composekey

Look at the complete table:

  • see user table: less ~/XCompose
  • see system table (scroll down!): less /usr/share/X11/locale/en_US.UTF-8/Compose

About keys and keyboard layouts:

Previous topic

Looking for Wisdom about Youtrack

Next topic

Looking for wisdom about typography

Tags

Archives

Languages

Recent Posts

This Page