Installing Python packages using pip on Ubuntu 24.04

Ubuntu 24 added some guarding for Python packages which no longer allows installing applications through pip on system level. Instead, you are presented with this error message:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use...

Installing Node.js / npm under Ubuntu with nvm (with yarn)

I recommend install Node.js using nvm. This way you can have multiple Node versions in your ~/.nvm. You also won't need to install global packages with sudo anymore.

Node via nvm will automatically bring npm. yarn will automatically be available if corepack is enabled for node.

Installing nvm

DigitalOcean has a HOWTO for installing nvm on Ubuntu (16.04, [18.04](https://www.digitalocean.com/community/tutorials/how-to-...

How to use Ubuntu in English, but still show German formats

If you want to have an English Ubuntu UI, but still see dates, money amounts, paper formats, etc. in German formats, you can fine-tune your /etc/default/locale like this:

LANG="en_US.UTF-8"
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"

Make sure you have both en...

AppArmor in Linux

This note is a reminder that there is something called AppArmor that could cause weird errors ("File not found", "Can't open file or directory", ...) after configuration changes, e.g. when changing MySQL's data directory.

Remember to have a look at AppArmor's daemon configuration (usually at /etc/apparmor.d/) if you change daemon configuration and run into errors such as the one above.

Install RubyMine under Ubuntu

This card explains how to install RubyMine for the first time. If you want to upgrade an existing RubyMine installation (after legacy install) to a newer version, see How to upgrade RubyMine.


Option A (new way)

Ubuntu 16.04 comes with snap, a way to package software with all its dependencies. RubyMine is also packaged as a snap.

A snap will always track a channel (like stable, beta) and automatically update to the newest version available in this channel. By default the snap daemon will check for ...

Ubuntu: Disable webcam microphone

If you want to system-wide disable the microphone of your external webcam in PulseAudio use the following one-liners:

# Connected cards
$ pactl list short cards
1       alsa_card.pci-0000_00_1f.3      module-alsa-card.c
5       alsa_card.usb-Lenovo_ThinkPad_Thunderbolt_4_Dock_USB_Audio_000000000000-00      module-alsa-card.c
6       alsa_card.usb-HD_Webcam_C270_HD_Webcam_C270-02  module-alsa-card.c

# Disable  HD_Webcam_C27
$ pactl list short cards | grep HD_Webcam_C27 | cut -f2 | xargs -rt -I % pactl set-card-profile % off
pactl s...

Linux: How to print PDF files from the command line

Sometimes you may want to print files from the command line, especially when you have lots of them.
You can use lp for that.

To print a single example.pdf file on your default printer, simply say:

lp example.pdf

lp accepts multiple filenames, so to print all PDF files in the current directory:

lp *.pdf

You can specify a printer via the -d switch:

lp -d YOUR_PRINTER_NAME *.pdf

Your printer's name is then one you defined on your system. You can check with your CUPS configuration by visiting `http://localhost:631/...

Manage Linux services on the command line (Ubuntu)

Ubuntu 18.04 uses systemd to manage services.

There are basically two commands for listing all services and manipulating the state of a certain service: service and systemctl:

  • service manages System V init scripts
  • systemctl controls the state of the systemd system and service manager. It is backwards compatible to System V and includes the System V services

Therefore I prefer to use systemctl.


See which services are there

>systemctl list-units -a --type=service
  UNIT                                 LOAD     ...

How to downgrade Google Chrome in Ubuntu

If you're experiencing problems with your Google Chrome installation after an update, it might help downgrading Chrome to check if the problem disappears. Keep in mind though that running outdated software, especially web browsers, is in most cases not a good idea. Please verify periodically if you still need to run the old version or if an even more recently updated version fixes the problems introduced in your version.

Here's how to get old versions of Chrome for your Ubuntu installation:

First, go to [UbuntuUpdates](https://www.ubuntuup...

RubyMine: How to restore the Back to last position shortcut on Ubuntu 20.04

I really love to use the shortcuts CTRL+Alt+ Arrow Left and CTRL+Alt+ Arrow Right to navigate through the code. It worked great on Ubuntu 18.04 and MATE but after migrating to my new notebook with GNOME and Ubuntu 20.04, I realized that the shortcuts didn't work anymore. Well, it worked via Navigate > Back and also showed the shortcut, but my fingers weren't able to do this...

I cried a lot. (Why God? WHY?)

Then I found this [thread on StackOverflow](https://stackoverflow.com/questions/47808160/intellij-idea-ctrlaltleft-short...

How to resize your boot partition when there is an encrypted partition after it

Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due to a full /boot partition, consider risizing it.

If you can't do the steps described below, ask someone experienced to help you out.
This has worked 100% so far. 1 out of 1 tries. ;)

Scenario A: There is unassigned space on your physical drive

When there is some unpartitioned space on your drive, increasing the size of /boot is actually very easy (even though the list below is rather long). It only takes a...

Installing old versions of mysql2 on Ubuntu 20.04+

On some of our older projects, we use the mysql2 gem. Unfortunately, versions 0.2.x (required for Rails 2.3) and versions 0.3.x (required for Rails 3.2) can no longer be installed on Ubuntu 20.04. Trying this either leads to errors when compiling the native extension, or a segfaults when using it.

For Rails 4.2, mysql2 version 0.4.10 seems to work okay. If you still have issues, upgrade to 0.5.x, which should be compatible.

To install it, you have to switch the mysql2 gem to our fork. In your Gemfile, ...

Making ZSH the default shell on Ubuntu 20.04

ZSH is an alternative command line shell that includes some features like spelling correction, cd automation, better theme, and plugin support. You can replace Bash with ZSH like following:

sudo apt-get install zsh

Setting ZSH as default login shell

sudo usermod -s /usr/bin/zsh $(whoami)

Opening a new terminal window will show you a dialog where you can configure your initial ZSH config (Option 2 recommended).

Afterwards you can install the plugin manager Oh-My-ZSH and select a prop...

Ubuntu: keyring password won't change with user password

Ubuntu might create several keyrings for you. Note that keyring passwords are initially set to the user password but do not change with it. If you can't seem to find the correct password for a keyring, try entering the inital password.

If you still can't find it, you might have to delete that keyring:

  • open "Passwords and Keys" (seahorse application)
  • right-click on the keyring you want to change
  • press Delete

How to install packages from newer Ubuntu releases

We're usually running Ubuntu LTS versions. Sometimes newer hardware requires packages from more recent Ubuntu releases that only come with 6 months of support. If there is really no other way, it's possible to install packages from later Ubuntu releases

Caution: Pay really close attention to what you're doing. Depending on the package, this process may require upgrading a lot of dependencies, possibly breaking the system! You really should not do this unless you've carefully calculated the impact on your system

Preparation

First,...

Sun Java JVM/JRE on Ubuntu Linux

Note that you should disable the Java plug-in in your browsers after installation.

Ubuntu >= 12.04

Java 11

sudo apt install openjdk-11-jre-headless

Java 10

sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java10-installer

Java 8

You probably want to get rid of OpenJDK (which is installed by default and leads to bad RubyMine performance):

...

RubyMine crashes Ubuntu 11.04 window decorator on exit

My RubyMine (and it seems like many other Java GUI applications) crashes the Compiz window decorator almost every time on exit. This also seems to happen for the Unity decorator.

Update: The commited fix from below seems to have made it into the stable Ubuntu repository.

Easy mode

You can restore window decorations by executing this command:

gtk-window-decorator --replace &

This is only a temporary fix.

Hard mode

Also, there is a committed fix that is n...

RubyMine: Restore main menu in Ubuntu

After a recent Ubuntu update I didn't see the main menu bar of the RubyMine IDE (File | Edit | View | ...) anymore.

This could be solved by changing a RubyMine registry entry:

  • Search "registry" within the "Actions" search
    • press ctrl + alt + n > click on Actions > type registry > click on Registry...
  • Scroll down to linux.native.menu and disable the checkbox

After rebooting RubyMine, you'll have gotten the menu bar back.

Install MySQL 5.6 in Ubuntu 16.04

Instead of using this hack you might want to use MariaDB 10.x which can work with both old and new apps.


An alternative could be to use the MySQL Docker image which is still updated for 5.6.


Ubuntu 16.04 only provides packages for MySQL 5.7 which has a range of backwards compatibility issues with code written against older MySQL versions.

Oracle maintains a list of official APT repositories for MySQL 5.6, but those repositories do...

Files open with an error "the location is not a folder" after installing XFCE

When using gnome-open (i.e. double-clicking a file, telling to browser to open a download, etc.) on Ubuntu you may get this error:

The location is not a folder.

It's due to the exo-utils package which does not play nice with gnome-open. You can fix the problem by uninstalling it:

sudo apt-get remove exo-utils

Note that this may also uninstall XFCE tools like xfce4-terminal or thunar (XFCE's directory browser). If you want to keep them, [try anot...

Installing RMagick on Ubuntu

When installing RMagick you may get an error messages like this:

Version 2.13.1:

checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /home/arne/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/bin

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
d...

Share your Internet connection under Ubuntu

This note describes how to setup a box running Ubuntu to share its Internet connection with another PC.

  • You will need two network interfaces to do this. One will connect to the Internet (e.g. UMTS card), one will share the connection with the other PC (e.g. Wired LAN).
  • On the Ubuntu PC, right-click on the connection symbol in the tray. Select Edit connections.
  • Switch to the wired LAN card. Go to Edit and set the method to Shared to other computers.
  • Connect the other PC to your wired LAN card. You can use the same cable that wo...

Setup an Ubuntu mirror that enables local release upgrades

Setup the mirror by following the steps described here.

If you want to enable OS upgrades using do-release-upgrade make sure you include $release-proposed packages in the mirror script, e.g., precise-proposed. Additionally, you have to add main/dist-upgrader-all to the $section in your script as debmirror silently ignores some directories.

I attached our modified script to include current releases

Enable Ubuntu release upgrade from the local mirror
--------------------------------------...

How to enable the Thinkpad microphone mute key on Ubuntu 16.04

While the hardware mute button of my Lenovo x230 worked on Ubuntu 14.04 out of the box, it does not on Ubuntu 16.04. It is fairly simple to fix, though.

There is an extensive answer on Ask Ubuntu, but only part of it was required for me. Here is the gist of it.

  1. Open a terminal

  2. Run acpi_listen and press the mute key. You should see something like this:

    button/f20 F20 00000080 00000000 K
    

    Press Ctrl+C to exit.

  3. Run amixer scontrols. You will see multiple lines, one of which sh...