The Ubuntu system does not use snap to install firefox, use the installation package downloaded from the firefox official website to install firefox

1. Origin

One day, I disliked snap taking up memory, and then I used the following command to uninstall snap

sudo apt autoremove --purge snapd

Then nothing happened...
then I turned it off, turned it on -
and then? ? ? ?
My firefox is gone, and other software is gone...

2. Find the reason record (the reason why snap was uninstalled before!!, this section mainly talks about snap, install firefox, you can ignore this section)

  1. Reinstall snap (in order to uninstall cleanly, the package installed by snap was not uninstalled before, it is directly sudo apt autoremove --purge snapduninstalled, it is not clean; it is also to see if firefox can be rescued, after all, there are so many bookmarks)

    sudo apt install snapd
    
  2. install firefox using snap

    sudo snap install firefox
    
  3. Looking at the snap installation list, there is firefox, and then I want to uninstall firefox, and an error is reported (note that if there is firefox behind disabled, you need to enable it first: sudo snap enable firefox)

    snap list
    

    insert image description here

  4. Click the firefox icon, run firefox, no response, can't run (so I want to see why firefox doesn't work before uninstalling snap)

  5. Terminal input firefox, firefox cannot be opened

    (base) fl@fl:~$ firefox
    cannot locate base snap core20: No such file or directory
    
  6. Solve: cannot locate base snap core20: No such file or directory problem

    sudo snap restart core20   # 失败,报错error: snap "core20" has no services,命令不对
    sudo snap enable  core20   # 失败,报错error: cannot enable "core20": snap "core20" already enabled
    # 上面失败的原因是,我命令使用错了,core20后面是broken,已经损坏了
    # 以下是正确的处理方式
    sudo snap remove bare core core18 core20 core22 cups
    snap install core20
    
  7. At this point the browser can run, but the bookmark is still gone, forget it, uninstall firefox, uninstall snap


uninstall snap


  1. See what packages are installed by snap
    snap list
    
  2. remove installed packages
    sudo snap remove --purge core20
    sudo snap remove --purge firefox
    ...
    sudo snap remove --purge gnome-3-38-2004
    sudo snap remove --purge gtk-common-themes 
    sudo snap remove --purge  htop
    sudo snap remove --purge  jupyter
    sudo snap remove --purge  onlyoffice-desktopeditors
    
  3. delete snap
    sudo apt autoremove --purge snapd
    sudo apt-get autoremove
    

3. Reinstall firefox (download the compressed package from the official website and install it)

  1. Download the compressed package from the official website
    Download link: https://www.firefox.com.cn/download/#product-desktop-release
    insert image description here

  1. Installation method 1 (no icon)
    • Unzip (if you don’t mind not having a firefox icon, you can only do this step every time you come to the place where you unzip and click to run firefox, and the next steps can be ignored; if you want to have a firefox icon, click the icon to run, you can skip this step )
      unzip to the path you want
      cd yourpath
      sudo tar -jxvf   Firefox-latest-x86_64.tar.bz2
      
    (Note: where j means to decompress the bz2 package, x means to decompress, v means to display the detailed process, and f means the file. After inputting the decompression command, the terminal will display the detailed process of decompression. If you don’t want to see the detailed process of decompression, you can modify -jxvf to -jxf)
    • Click firefox (picture below) to start the Firefox browser
      insert image description here
      (Note: I downloaded Firefox-latest-x86_64.tar.bz2, after decompression, firefox is the execution program, some versions may be firefox.sh, you need to run it yourself, There are also some ./configure that need to be made by yourself, please take a look)

  1. Installation method 2 (with icon)

    • Enter the path where the firefox compressed package is stored, and then decompress it into /usr/lib/

      cd  你放firefox压缩包的地方
      sudo tar -jxvf Firefox-latest-x86_64.tar.bz2  -C /usr/lib/
      

      (Note: -C means to change the path (change), you need to bring this option to decompress it into /usr/lib normally)

    • At this point you run firefox, no response, need to create a link
      insert image description here

    • Create a link to /usr/bin/, so that it can be run in the terminalfirefox

      sudo ln -s /usr/lib/firefox/firefox /usr/bin/
      

      insert image description here

    • Check the version number of firefox, which will be used later

      firefox --version
      

      insert image description here


      Start making icons


    • Go to the applications folder

      cd /usr/share/applications
      
    • Write configuration file (using vim)

      sudo vi firefox.desktop
      
    • Enter in the file firefox.desktop (there is a permission problem, click to open it later, add content in it, it will not be saved, so you need to use sudo vi firefox.desktop, that is, create the file firefox.desktop, and use sudo to increase the permission) Enter The following content, and then enter in the command line :wqto save and exit (wq: you can see how the vim command works)

      [Desktop Entry]
      Name=Firefox 107.0 
      Comment=this is firefox
      Exec=/usr/lib/firefox/firefox
      Icon=/usr/lib/firefox/browser/chrome/icons/default/default64.png   
      Terminal=false
      Type=Application
      Categories=Application;Network;
      

      insert image description here
      Instructions: (To modify comments and files, you need to press i: Here also see how vim modifies files)

      [Desktop Entry]
      Name=Firefox 107.0   # 运行firefox --version 进行对应修改
      Comment=this is firefox
      Exec=/usr/lib/firefox/firefox
      Icon=/usr/lib/firefox/browser/chrome/icons/default/default64.png   #需要修改到有firefox图标的路径下,一般/usr/lib/firefox/browser/chrome/icons/default;  /usr/lib/firefox/icons两个路径下有,如果没有,自己下载图片放在这里面,图片一般为48x48的
      Terminal=false
      Type=Application
      Categories=Application;Network;
      

      At this point, you have the firefox icon, you can click the icon to run firefox

Reference in this article:
get firefox icon: https://blog.csdn.net/jjzhoujun2010/article/details/6694552
file decompression: https://jingyan.baidu.com/article/86fae3461437c53c48121a50.html
other snap installation, uninstallation and other articles

Guess you like

Origin blog.csdn.net/weixin_43686259/article/details/127883315