Category: Ubuntu

  • How to convert images to webp format in Ubuntu

    How to convert images to webp format in Ubuntu

    Webp is a new image format for the web. It can be used on websites for the fast and efficient loading of images. Webp is an open-source image format created by Google and quickly getting adopted by web developers.

    If you use Ubuntu or Debain, you can install webp from the official repository with the command

    sudo apt-get install webp
    

    To convert an image to webp format, open the terminal and run

    cwebp FILE.png -o FILE.webp
    

    If you want to specify the quality of the converted webp image, you can use -q option.

    cwebp -q 60 FILE.png -o FILE.webp
    

    Image viewer comes with Ubuntu won’t display webp images. To view webp images, you can open them in the GIMP image editor or drag and drop them in a web browser. Another way is to use the command-line tool that comes with webp package.

    vwebp FILE.webp
    
  • Install CSF firewall on Ubuntu Server

    Install CSF firewall on Ubuntu Server

    First, install libwww-perl package needed for CSF firewall

    apt -y install libwww-perl
    

    Install CSF with

    cd /usr/local/src
    wget https://download.configserver.com/csf.tgz
    tar -xzf csf.tgz
    cd csf
    sh install.sh
    

    Change following settings in csf.conf file

    /bin/sed -i "s/RESTRICT_SYSLOG\s*=.*$/RESTRICT_SYSLOG = \"3\"/g" /etc/csf/csf.conf
    /bin/sed -i "s/SYSLOG_CHECK\s*=.*$/SYSLOG_CHECK = \"3600\"/g" /etc/csf/csf.conf
    /bin/sed -i "s/TESTING = \"1\"/TESTING = \"0\"/g" /etc/csf/csf.conf
    

    If you need GUI enabled, edit file

    vi /etc/csf/csf.conf
    

    Modify following settings

    UI = "1"
    UI_PORT = "8282"
    UI_USER = "username"
    UI_PASS = "password"
    UI_ALLOW = "0"
    
  • dpkg dependency problems not removing

    dpkg dependency problems not removing

    When removing a package, I got the following error message

    root@82-165-118-245:/~# dpkg --remove psa-phpmyadmin
    dpkg: dependency problems prevent removal of psa-phpmyadmin:
     plesk-core depends on psa-phpmyadmin (>= 5.1.1); however:
      Package psa-phpmyadmin is to be removed.
    
    dpkg: error processing package psa-phpmyadmin (--remove):
     dependency problems - not removing
    Errors were encountered while processing:
     psa-phpmyadmin
    root@82-165-118-245:/~# 
    

    It is fixed by specifying –ignore-depends=plesk-core in apt command.

    Example

    root@82-165-118-245:/~# dpkg --remove --ignore-depends=plesk-core psa-phpmyadmin
    (Reading database ... 168316 files and directories currently installed.)
    Removing psa-phpmyadmin (5.1.1-v.ubuntu.18.04+p18.0.38.0+t210825.1032) ...
    root@82-165-118-245:/~# 
    
  • dpkg package pre-removal script returned error

    dpkg package pre-removal script returned error

    On a Plesk server, MySQL somehow went missing. When I tried to remove a package, I get error

    root@82-165-118-245:~# dpkg --remove plesk-config-troubleshooter
    (Reading database ... 168528 files and directories currently installed.)
    Removing plesk-config-troubleshooter (18.0-v.ubuntu.18.04+p18.0.39.2+t211117.1817) ...
    dpkg action: 
    
    ERROR while trying to detect MySQL service name
    
    Check the error reason (see log file: /var/log/plesk/install/plesk_18.0.39_installation.log), fix and try again
    dpkg action: 
    
    ERROR while trying to detect MySQL service name
    
    
    Package script failed
    
    ***** installing problem report *****
    ERROR while trying to detect MySQL service name
    Package script failed
    dpkg: error processing package plesk-config-troubleshooter (--remove):
     installed plesk-config-troubleshooter package pre-removal script subprocess returned error exit status 1
    Errors were encountered while processing:
     plesk-config-troubleshooter
    root@82-165-118-245:~#

    To fix this, I removed the prerm and postrm scripts. These scripts execute before and after a package is removed. It is not recommended to remove it, but if these scripts prevent you from uninstalling a package, you can remove them as the last option.

    mv /var/lib/dpkg/info/plesk-config-troubleshooter.prerm ~/
    mv /var/lib/dpkg/info/plesk-config-troubleshooter.postrm ~/

    Or you can just edit the file, put

    exit 0

    somewhere before the error happens.

  • Convert image to WebP format in Ubuntu

    Convert image to WebP format in Ubuntu

    WebP is an image format for web by Google. The size of webp images are much smaller compared with other image formats, so better to use webp images on websites for faster site load speed.

    To install webp on Ubuntu/Debian, run

    sudo apt install webp
    

    To convert an image to webp format, run

    cwebp image.png -o image.webp
    

    With the above command, image.png file gets converted to image.webp

    You can specify quality with -q option

    -q  ............. quality factor (0:small..100:big), default=75
    

    To view a webp image, run

    vwebp image.webp
    
  • bash: /usr/bin/man: No such file or directory

    bash: /usr/bin/man: No such file or directory

    On Ubuntu, I get the following error

    root@vps1:~# man
    bash: /usr/bin/man: No such file or directory
    root@vps1:~#
    

    This is fixed by installing man with apt-get

    apt-get install man
    
  • How to disable GUI in Ubuntu

    How to disable GUI in Ubuntu

    If you have installed Ubuntu with GUI and don’t want GUI, you can disable GUI from starting on boot with command

    systemctl set-default multi-user
    

    If you need to GUI auto-start on boot, run

    systemctl set-default graphical.target
    
  • Configure Failover IP in Ubuntu 20.04 OVH VPS

    Configure Failover IP in Ubuntu 20.04 OVH VPS

    To configure IP on OVH VPS, you need to manually configure networking as OVH gateway is outside the failover IP subnet. For most hosting providers getaway will be in the same subnet as the IP address. To configure IP using netplan, see instruction here.

    First, install ifupdown package

    apt install -y ifupdown
    

    Now edit file

    vi /etc/network/interfaces
    

    Add

    auto NETWORK_INTERFACE_HERE
    iface NETWORK_INTERFACE_HERE inet static
        address FO_IP_ADDR
        netmask 255.255.255.255
        broadcast FO_IP_ADDR
        dns-nameservers 8.8.8.8 8.8.4.4
        post-up ip route add GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
        post-up ip route add default via GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
        pre-down ip route del GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
        pre-down ip route del default via GATEWAY_ADDR dev NETWORK_INTERFACE_HERE
    

    In the above text, replace

    NETWORK_INTERFACE_HERE = with your actual network interface name, for example, eth0, ens18, etc.
    FO_IP_ADDR = Your VPS IP address, OVH calls this Failover IP address. It is just any secondary IP address you purchase.
    GATEWAY_ADDR = Gateway IP address. This is the same as the Main IP of the server with the last octal replaced by 254

    Example

    Ubuntu 20.04 failover IP

    Configuration is the same as Ubuntu 18.04, the only difference is post-up and pre-down tines, where Ubuntu 18.04 used older route command, in Ubuntu 20.04, we use “ip route” command instead.

  • Module php-imagick in this instance has no SVG support

    Module php-imagick in this instance has no SVG support

    On Ubuntu server running Nextcloud, I got the following warning in Nextcloud

    Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.
    

    To fix this warning, install libmagickcore-6.q16-6-extra package with the command

    apt-get install libmagickcore-6.q16-6-extra
    

    See Nextcloud

  • How to install zabbix agent on Ubuntu

    How to install zabbix agent on Ubuntu

    To install the Zabbix agent on Ubuntu, run the command

    apt install zabbix-agent
    

    To autostart, Zabbix agent on boot, enable it with

    systemctl enable zabbix-agent
    

    To manage Zabbix, use commands

    systemctl stop zabbix-agent
    systemctl start zabbix-agent
    systemctl restart zabbix-agent
    

    To see Zabbix listening port

    netstat -lntp | grep zabbix
    

    Zabbix agent port

    Edit file

    vi /etc/zabbix/zabbix_agentd.conf 
    

    Find

    Server=127.0.0.1
    

    Replace with

    Server=127.0.0.1,IP_OF_ZABBIX_SERVER_HERE
    

    zabbix agent Server config

    Restart zabbix agent

    systemctl restart zabbix-agent
    

    After the Zabbix agent is installed, you need to add the sevrer in your Zabbix installation.

  • How to install development tools on Debian/Ubuntu

    Development tools are programs used to build software from its source code. These include compilers, make, and other generally used libraries.

    To install development tools on Ubuntu/Debian, run

    apt install -y build-essential
    apt install -y autoconf automake gdb libffi-dev zlib1g-dev libssl-dev git wget

    See Ubuntu, Debian

  • bash: lspci: command not found

    On Ubuntu server, when I run lspci command, I get the error

    root@first-vm:~# lspci
    -bash: lspci: command not found
    root@first-vm:~# 

    To fix this error, install the package pciutils

    apt install -y pciutils

    See lspci