7

A new user here, running ubuntu on version 21.10 impish.

I was installing youtube-dl with the instructions on the github page (https://github.com/ytdl-org/youtube-dl#installation):

$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl

After the commands had downloaded the python script, multiple applications stopped functioning completely, as if they had been replaced by youtube-dl [UPDATE 3: the applications themselves weren't replaced, merely their links and shortcuts]. Some of the software affected were Ubuntu's default applications, like the default text editor (gedit) and the gnome-calculator, while others were manually installed like qbittorrent and steam.

Some things like firefox, nano, and lutris are still working.

Trying to run the text editor for example from terminal results in following output:

$ gedit

Usage: gedit [OPTIONS] URL [URL...]

gedit: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

The error is same with all the affected applications:

$ gnome-calculator

Usage: gnome-calculator [OPTIONS] URL [URL...]

gnome-calculator: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

Only thing I've tried so far is reinstalling gedit via apt but nothing changed.

I'd like to know what went wrong, and if it's fixable or if I need to do a reinstall.

UPDATE 1: Outputs of requested commands:

$ history 

  867  sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
  868  sudo chmod a+rx /usr/local/bin/youtube-dl
  869  youtube-dl sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
  870  sudo chmod a+rx /usr/local/bin/youtube-dl

No clue why it seems be listed twice.

$ which gedit
/usr/local/bin/gedit

$ which gnome-calculator
/usr/local/bin/gnome-calculator

$ ls -al $(which gedit)
lrwxrwxrwx 1 root root 17 loka   28 19:55 /usr/local/bin/gedit -> /usr/bin/firejail

$ ls -al $(which gnome-calculator)
lrwxrwxrwx 1 root root 17 loka   28 19:55 /usr/local/bin/gnome-calculator -> /usr/bin/firejail

$ file $(which gedit)
/usr/local/bin/gedit: symbolic link to /usr/bin/firejail

$ file $(which gnome-calculator)
/usr/local/bin/gnome-calculator: symbolic link to /usr/bin/firejail

"loka" seems to be short for October, I've got the system in English but the date seems to still use Finnish.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

UPDATE 2: further requested command outputs from :

The fsck ran via a thumb drive

$ sudo fsck -p /dev/nvme0n1p1
fsck from util-linux 2.36.1
fsck.fat 4.2 (2021-01-31)
/dev/nvme0n1p1: 11 files, 1336/130812 clusters

$ sudo fsck -p /dev/nvme0n1p2
fsck from util-linux 2.36.1
/dev/nvme0n1p2: clean, 478908/31227904 files, 49277410/124895488 blocks

Back on the system:

$ whereis gedit
gedit: /usr/bin/gedit /usr/lib/x86_64-linux-gnu/gedit /usr/local/bin/gedit /usr/share/gedit /usr/share/man/man1/gedit.1.gz

$ sha256sum /usr/bin/gedit /usr/local/bin/youtube-dl
27545f7fb059c356feeb88a872719c074d0fd5169564ec3fbb3cbb312b093184  /usr/bin/gedit
7880e01abe282c7fd596f429c35189851180d6177302bb215be1cdec78d6d06d  /usr/local/bin/youtube-dl

Tried to use sudo ldconfig as well, as suggested by the answer, but got no output nor did anything seemingly change.

UPDATE 3: Just now found out that all the affected software still work with the full path (e.g./usr/bin/gedit), the issue seems to have to do with links and shortcuts to these applications. Things like the right-click option "Open with Text Editor" is also still broken.

5
  • 6
    I'd venture a guess that you typed something wrong with those 2 sudo commands. Can you find them in the output of history and confirm that what was typed was what was expected? Commented Dec 25, 2021 at 2:21
  • 1
    Can't reproduce on fresh VM. Please add the output of the following commands to the question: which gedit, which gnome-calculator, ls -al $(which gedit), ls -al $(which gnome-calculator), file $(which gedit), file $(which gnome-calculator), echo $PATH.
    – N0rbert
    Commented Dec 25, 2021 at 7:22
  • 4
    Does this answer your question? How can I update youtube-dl?
    – karel
    Commented Dec 25, 2021 at 7:22
  • Btw I recommend installing from pip instead from apt because it will be more up-to-date. Also youtube-dl is currently paused as a project so consider yt-dlp fork for the time being.
    – qwr
    Commented Dec 26, 2021 at 8:03
  • And this, kids, is why you don't run arbitrary scripts from the internet as root. Commented Dec 27, 2021 at 0:10

1 Answer 1

22

Here is a theory:

Before you ran the first command, /usr/local/bin/youtube-dl already existed and was a symlink to /usr/bin/firejail. Probably from some previous installation.

The curl ... -o /usr/local/bin/youtube-dl command does not replace the existing symlink with a new file. Instead it overwrites the contents of the file, which overwrites /usr/bin/firejail. Normally this is a multicall binary that checks the name it is called with and executes the actual application in a sandbox. But the youtube-dl code of course does nothing of that.

As confirmed in the comments, reinstalling firejail replaces /usr/bin/firejail with a working version.


For reference, the typical firejail configuration setup by firecfg works like this: for each sandboxed application, there is a symbolic link under /usr/local/bin that points to /usr/bin/firejail. The real executable is in /usr/bin and gets executed inside the sandbox. That is also why starting the programs with a full /usr/bin path still works, but the default path selects the symlink instead.

2
  • Nice analysis! I learned from this. Commented Dec 25, 2021 at 19:06
  • 2
    I just came back to write something similar, now I don’t have to. Since the damage was limited, I actually find this somewhat amusing, because without the additional information that was added into the question, it did indeed look rather implausible.
    – Carsten S
    Commented Dec 25, 2021 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .