Click here for archives 2005-2019

How to sudo when sudo stopped working on Ubuntu Desktop

Published: Wed Sep 20 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Got into a situation on a Ubuntu desktop Linux where the sudo configuration files had the wrong ownership and I could not change it back because, I had no sudo anymore. Turns out there is another way on Ubuntu Desktop (at least) to execute commands with elevated privileges: pkexec.

Just prefix in the CLI with pkexec what it is you want to do and you'll get a GUI dialog to enter your password.

It uses a different authorization system than sudo it seems, from its man page:

"By default, the org.freedesktop.policykit.exec authorization is required unless an action definition file is present for the program in question. To require another authorization, it can be specified using the org.freedesktop.policykit.exec.path annotation on an action (See the section called “EXAMPLE” for details)."

How to stream sound from your Linux/pipewire computer to your mobile phone

Published: Thu Jul 27 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

The computer is assumed to run pipewire for its sound system.

First, install icecast on a server somewhere, e.g., port 8000

Secondly, install VLC on your phone.

Then, install gstreamer and its plugins on the computer, e.g:

sudo apt install gstreamer1.0-plugins-good

Figure out the number of the sound device that you want to stream:

pw-cat -r --list-targets

Let's say it's 50. On my computer that is the number for the monitor source, which will be unaffacted by the volume levels of the computer.

Then issue this command line:

gst-launch-1.0 pipewiresrc path=50 ! \
audioconvert ! vorbisenc ! oggmux ! \
shout2send mount=/stream.ogg port=8000 username=source \

There may be extraneous stages in the pipeline above. But it works.

Update 2023-07-30

However for me, there was still one small problem: The volume was too low after coming out from icecast. However there is a pipeline stage you can put in with the plugin audioamplify which solved that problem.

So now the pipeline in Gstreamer looks like this:

gst-launch-1.0 pipewiresrc path=50 ! \
audioconvert ! audioamplify amplification=4 ! \
vorbisenc ! oggmux ! \
shout2send mount=/stream.ogg port=8000 username=source \

There is also a Gstreamer volume plugin, but it can only attenuate.

How to pad a video with ffmpeg to e.g. have even dimensions

Published: Mon Jun 26 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Made a small screencast and unfortunately it had odd dimensions, which worked fine in the webm format it was produced, but could not be converted to e.g. mp4 or mov with the default settings of ffmpeg.

I don't want to resize it, can a black border just be added to even it out? Yes. The trick turned out to be to specify a bigger size for the output video with "pad". Let's say the video is orginally 593x575, and then just quick and dirty make the output 600x600:

ffmpeg -i odd.webm -vf "pad=width=600:height=600:x=0:y=0:color=black" even.mp4

And then you specify with x and y where the video should be placed within that padding. Simplest is to just put it in the upper right corner, with x=0:y=0.


Grep tricks

Published: Wed May 17 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

grep helped 3 times one week.

Overwrote precious text file. Got it back in minutes with:

sudo grep -i -a -B100 -A100 'some text in file' /dev/mapper/vg-root > files.txt

Found lines in common between two files:

grep -Fxf file1 file2

Prefix lines with file name:

grep .  . file

Serving a home server through an Internet server via Wireguard

Published: Fri May 05 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Note, this is experimental. But seems to work.

A common way of serving data from a home server on the Internet is to punch a hole through the NAT server that hides the home network, and then dynamically update the IP number of the home server, behind an address, something like . But that exposes the home server to the Internet and to any client.

But couldn't you use a VPN instead? The idea being that an Internet server has a Wireguard server, and the home server connects to it as a client. This should mean that it does not matter if the home server changes IP. Wireguard will handle that behind the scenes.

It seems to work. We may normally think of a VPN as the possibility for a client to reach servers on a protected network, but the Wireshark server (and I guess the entire network) can also see the ports of the connecting client.

One thing to think of is that the services on the home server must listen on the Wireguard interface.

I've tested the setup and it worked. I used an nginx proxy on the Internet server, that then connected to the IP number of the home server on the VPN Network. On the home server there was then an application server running, listening on the Wireguard interface.

Linux firewalls - I selected firewalld

Published: Fri May 05 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Experimenting a bit with having servers at home, but published on the Internet via WireGuard. Felt I needed a firewall for the home server, even though only the Internet server can see it through Wireguard. I found ufw more difficult to understand, so went with firewalld.

Some initial impressions of firewalld and ufw wrt wireguard

Published: Sat Apr 15 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Got to look into the world of firewalls, long time since I used one, which back then was arno I used.

Firewalls on Linux seem to be a thin layer on top of iptapbles or nftables. They all manipulate rules and try to make it easier for the user/admin to configure. But in the end it's whatever teh underlying itables or nftables does, that is the truth.

My usecase was a bit special: I wanted to see if a local machine behind a NAT witrunningh wireguard as a client, could be used as a web server on the Internet. Turns out it can, but it felt prudent to put an additional firewall on teh server itself, since there did not seems

How to stop VS Code from autocompleting plain text to god knows what

Published: Sun Mar 26 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Make a language-specific setting like this (in your settings.json):

"[plaintext]": { "editor.quickSuggestions": { "other": false, "comments": false, "strings": false } }

This goes inside the bracket already in that file. Also to get to JSON mode you have to first click a little icon at the top right.


How to get rid of lots of fonts on Ubuntu in scripts you don't read or write

Published: Fri Mar 24 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

I used info from this guy's page:

This command came in handy to spot any straddlers:

sudo dpkg -l fonts\*|grep ^ii|awk '{print $2}'

xxhashsum a fast hashing algo in standard ubuntu repos

Published: Thu Mar 23 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

It was 3x faster than sha256sum in my tests, but that includes a lot of just file I/O. So it must be comparatively a lot faster than that.

Getting a separate Chromium to translate to English

Published: Mon Feb 20 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

I decided to use a different Chromium profile for running some extensions, including translation extensions. Problem is I'm running under a Swedish locale, and me changing settings to translate into English in the extensions did not work; they were just ignored.

Finally in the custom desktop file I've made in order to launch a separate profile for Chromium, I put in a language environment variable on the execution line:

Exec=env LANGUAGE=en chromium --user-data-dir=/path/to/my/custom/profile/directory

Trying to fix resume problems on Ubuntu 22.04 with Nvidia

Published: Thu Feb 09 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

A certain error message: "Freezing of tasks failed after 20.009 seconds", led me to this discussion on Nvidia.

Now installed it, will have to wait and see if it works.

As described in the comment, more or less:

sudo nano -w /usr/local/bin/

And put in:


case "$1" in
        killall -STOP gnome-shell
        killall -CONT gnome-shell

sudo nano -w /etc/systemd/system/gnome-shell-suspend.service

and put in:

Description=Suspend gnome-shell

ExecStart=/usr/local/bin/ suspend


sudo nano -w /etc/systemd/system/gnome-shell-resume.service

and put in:

Description=Resume gnome-shell

ExecStart=/usr/local/bin/ resume


Enable the two new systemd units:

sudo systemctl daemon-reload
sudo systemctl enable gnome-shell-suspend
sudo systemctl enable gnome-shell-resume

Gnome-shell consumed CPU, disabling Ubuntu AppIndicators solved it

Published: Wed Feb 08 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Ubuntu 22.04 LTS

  1. sudo apt install gnome-shell-extension-prefs
  2. Open the Extensions app
  3. Disable Ubuntu AppIndicators

That was enough for me. Enabling them again also worked.


Decompress files — unp seems to do what dtrx did

Published: Wed Feb 01 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Had some files that needed unpacking and was reaching for dtrx, but wasn't installed and also not in the Ubuntu repos. Found unp which seems to do more or less the same thing. Haven't tried it on zip files to unzip, tarballs, 7zip or other stuff yet though. Just .xz .

Getting gratis DaVinci Resolve 18.0 to work on Ubuntu 22.04

Published: Sun Jan 29 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Video formats

The final thing that made it work was realising that not all video formats are accepted by the free version. It will happily import them, but they can not be dragged on to the time line. Or if you succeed in creating a new timeline with them on, nothing is played as the play head traverses through them. This ffmpeg script seems to work to convert files:

ffmpeg -i infile.mp4 -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov

Described here: , In fact there is listed a batch command:

mkdir transcoded; for i in *.mp4; do ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "transcoded/${i%.*}.mov"; done

Video card always on

It seems you need an external video card to run Resolve too, and the card must be active when running the installation script. Or you will get missing license key once you run the application with the graphics card.

Not that there comes any license key with the free version.

In order to switch to the card being always on I used the nvidia-settings app. I tried to do it also with some CLI command but it did not seem to stick.

Disable middle click actions from the mouse in Ubuntu 22.10

Published: Sun Dec 25 2022 00:00:00 GMT+0000 (Coordinated Universal Time)

Summary: No system wide setting has worked for me so far. You can open about:config in Firefox, search for "middle" and set to false as much as you can find there. In VS code you can search for "editor.selectionClipboard" and set it to false.

A dodgy mouse keeps middle clicking when the scroll wheel is used. This lead to a flurry of new tabs in Firefox and text all over the place in VS Code.

See: for the VS Code setting.

How to install Chromium with apt-get on Ubuntu so you can use extensions that need to reach out

Published: Sun Dec 25 2022 00:00:00 GMT+0000 (Coordinated Universal Time)

Summary: Use a repository from the Linux Mint distribution. Promote chromium there and demote everything else from that Mint repository.Mint is like Ubuntu, but have decided to not go down the snap path.


The instructions are copied from here with very light editing such as a newer Mint (una → vera) :

Make a backup of the stuff from the snap chromium you want to keep, such as bookmarks

Uninstall snap's Chromium, and if you installed it via apt, remember to also uninstall chromium-browser there or you will get a conflict that prevents Mint's Chromium from being installed

Create an apt source file for the Mint repository:

echo "deb vera upstream" | sudo tee /etc/apt/sources.list.d/mint-vera.list

To prevent NO_PUBKEY you have to add the GPG key by this:

sudo apt-key adv --recv-keys --keyserver A1715D88E1DF1F24 40976EAF437D05B5 3B4FE6ACC0B21F32 A6616109451BBBF2

Then update package lists by apt: sudo apt update

Prevent installation of other packages by pin-file:

cat <<EOF | sudo tee /etc/apt/preferences.d/pin-chromium
Package: *
Pin: release o=linuxmint
Pin-Priority: -1
Package: chromium
Pin: release o=linuxmint
Pin-Priority: 1000

Install chromium:

sudo apt install chromium

Snap will be able to do it in the future

Some browser extensions cannot work with snap versions of Firefox and Chromium and snap is what Ubuntu offers nowadays. The snap people are working on making extensions that need to communicate outside the sandbox to work in both in Firefox and Chromium, and it seems they have a solution you can use for Firefox, if you snap install firefox-beta. Untested by me. Once they get the irons wrinkled out as one says, they will make this work for Firefox normal and for Chromium.


A proxy server inside of the Chromium snap

You could conceivable get some glue to work inside the snap for e.g. Chromium, similar to this guide for Firefox and Flatpak:

In that case you'd put a proxy binary inside the snap and some JSON for the browser.

If Ubuntu Linux on the desktop was a car

Published: Sun Dec 25 2022 00:00:00 GMT+0000 (Coordinated Universal Time)

If Ubuntu Linux on the desktop was a car

Today when I went out to the garage, two wheels were missing from the car. After some searching it turned out to be a conflict between the mechanic and the guy who changes the wheels to winter tyres. I pinned the mechanic to the ground and praised the tyre guy a 1000 times, and the wheels snapped on again.

A security update (UPS update) had disabled old unsafe driving modes such as driving in reverse. It was just a question of going under the engine hood to file off two serial numbers and I could after a restart, back out of the garage.

The car keeps middle-honking when I turn the steering wheel but there is no workaround as of right now.

How to know if your Linux machine is on 5GHz WiFi and what channel

Published: Fri Dec 09 2022 00:00:00 GMT+0000 (Coordinated Universal Time)

In a terminal, just issue:


And for one network interface you will get something like this, where "5.18GHz" indicates you're on the higher band:

wlp1s0    IEEE 802.11  ESSID:"My dual band WiFi"  
      Mode:Managed  Frequency:5.18 GHz  Access Point: FF:FF:FF:FF:FF:FF   
      Bit Rate=6 Mb/s   Tx-Power=20 dBm   
      Retry short limit:7   RTS thr:off   Fragment thr:off
      Power Management:on
      Link Quality=51/70  Signal level=-59 dBm  
      Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
      Tx excessive retries:0  Invalid misc:0   Missed beacon:0

If you want to know what channel you're on you can install the iw command e.g. with apt on Ubuntu and get something like this:

Interface wlp1s0
    ifindex 3
    wdev 0x1
    addr ff:ff:ff:ff:ff:ff
    type managed
    wiphy 0
    channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz
    txpower 20.00 dBm
    multicast TXQ:
        qsz-byt    qsz-pkt    flows    drops    marks    overlmt    hashcol    tx-bytes    tx-packets
        0    0    0    0    0    0    0    0        0

which indicates channel 36 in this case. But I guess that was probably obvious from the frequency anyway in the previous query?


Pipewire got the sound back for YouTube videos on Ubuntu 22.04

Published: Mon Nov 14 2022 00:00:00 GMT+0000 (Coordinated Universal Time)

Sound disappeared in Firefox sometimes and did not come back, while playing YouTube videos. Only recourse seemed to be to restart the computer! I got it back by installing a new sound system called pipewire, see instructions here:

Seems to be a problem for a certain Intel chipset?

Discussion here: