Tag: Ubuntu

  • Ubuntu 18.04 MariaDB 10.2 Too many open files

    Ubuntu 18.04 MariaDB 10.2 Too many open files

    On my computer running Ubuntu 18.04, MriaDB stopped working. PHP application i run on my computer failed with error

    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ok_test.feeds' doesn't exist (SQL: select * from `feeds` where `processed` = 0)
    

    Application can’t find the table. So i tried to login to MySQL and see if table is there or not. But i get error

    boby@sok-01:~$ mysql
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2504
    Server version: 10.2.30-MariaDB-1:10.2.30+maria~bionic-log mariadb.org binary distribution
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> show databases;
    ERROR 1018 (HY000): Can't read dir of '.' (errno: 24 "Too many open files")
    MariaDB [(none)]>
    

    Next i checked if this is due to any MySQL upgrade. I found MySQL got updated today

    root@sok-01:~# grep mariadb /var/log/dpkg.log
    2019-12-13 08:02:46 status triggers-pending mariadb-server-10.2:amd64 1:10.2.29+maria~bionic
    2019-12-13 08:02:46 upgrade mariadb-common:all 1:10.2.29+maria~bionic 1:10.2.30+maria~bionic
    2019-12-13 08:02:46 status half-configured mariadb-common:all 1:10.2.29+maria~bionic
    2019-12-13 08:02:46 status unpacked mariadb-common:all 1:10.2.29+maria~bionic
    2019-12-13 08:02:46 status half-installed mariadb-common:all 1:10.2.29+maria~bionic
    

    To fix this error, run

    systemctl edit mysql
    

    This wil open a text editor. Add following

    [Service]
    LimitNOFILE=8192
    

    Save and quit the editor. Restart MaraDB with

    systemctl restart mysql
    

    MySQL will work properly now. systemctl edit mysql will create file /etc/systemd/system/mysql.service.d/override.conf

    root@sok-01:~# cat /etc/systemd/system/mysql.service.d/override.conf 
    [Service]
    LimitNOFILE=8192
    
    root@sok-01:~#
    
  • Disable Native Notification on Google Chrome Ubuntu

    On Ubuntu, Google chrome had a disable native notification option. On Chrome 78, this option is removed. But you still can manually enable it.

    To enbale chrome notification, edit file

    gedit ~/.config/google-chrome/Local\ State
    

    Find

    "tab-hover-cards@4"
    

    Replace with

    "enable-native-notifications@2","tab-hover-cards@4"
    

    Save and exit the file. Now restart google chrome.

    Related Posts

    Google Chrome

  • debconf: unable to initialize frontend: Dialog

    When installing a program in Ubuntu 18.04 server minimal installation, i get following error

    debconf: unable to initialize frontend: Dialog
    debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
    debconf: falling back to frontend: Readline
    

    To fix this, run

    apt -y install whiptail
    

    OR

    apt -y install dialog
    

    Related Posts

    Errors

    apt

  • Install NextCloud Desktop client on Ubuntu

    Install NextCloud Desktop client on Ubuntu

    To install NextCloud desktop client on Ubuntu, add PPA

    sudo add-apt-repository ppa:nextcloud-devs/client
    sudo apt-get update
    

    Now run

    sudo apt install nextcloud-client
    

    After install, start nextcloud client, you will be able to login with nextcloud server URL, user and password.

    NextCloud ubuntu client

  • Linux KVM Bridge network on Ubuntu

    On Ubuntu 18.04 server, first i get Ubuntu to use /etc/network/interface, by default Ubuntu 18.04 and newer use netplan.

    First install ifdown

    apt install ifupdown -y
    

    Install bridge utils and resolvconf.

    apt install bridge-utils resolvconf
    

    Now you can configure your network interface by editing file

    vi  /etc/network/interface
    

    Here is my network configuration on an OVH server.

    root@ns3048991:~# cat /etc/network/interfaces
    # interfaces(5) file used by ifup(8) and ifdown(8)
    # Include files from /etc/network/interfaces.d:
    source-directory /etc/network/interfaces.d
    
    auto eno3
    iface eno3 inet static
        address 149.202.199.137
        netmask 255.255.255.255
        broadcast 149.202.199.137
        gateway 149.202.199.254
        dns-nameservers 8.8.8.8 8.8.4.4
    root@ns3048991:~# 
    

    To convert this interface to bridge network, do the following

    1) Replace all occurance of “eno3” with “br0”

    2) Add following lines

        bridge_ports eno3
        bridge_stp off
        bridge_maxwait 5
    

    In above, replace “eno3” with name of your physical interface.

    Here is my final network configuration.

    root@ns3048991:~# cat /etc/network/interfaces
    # interfaces(5) file used by ifup(8) and ifdown(8)
    # Include files from /etc/network/interfaces.d:
    source-directory /etc/network/interfaces.d
    
    auto br0
    iface br0 inet static
        address 149.202.199.137
        netmask 255.255.255.255
        broadcast 149.202.199.137
        gateway 149.202.199.254
        bridge_ports eno3
        bridge_stp off
        bridge_maxwait 5
        dns-nameservers 8.8.8.8 8.8.4.4
    root@ns3048991:~# 
    

    See Linux KVM, Networking @ linux-kvm.org

  • Install  Xfce VNC remote desktop on Ubuntu

    Install Xfce VNC remote desktop on Ubuntu

    XFCE is a lightweight Desktop Environment for Linux. XFCE + vnc allows you to set up a remote desktop on a VPS or dedicated server located in a remote data center or cloud. You can connect to remote desktop using a VNC client and work like it is a local computer, similar to Windows Remote Desktop (RDP).

    To install XFCE run

    apt install -y xfce4 xfce4-goodies
    

    You will be asked to select Default Display Manager. You can select any of the options.

    Next install vncserver

    apt install tightvncserver autocutsel
    

    It is a bad idea to use root user for logging into the desktop. Create a normal user with sudo privileges to be used as desktop user.

    useradd -m -s /bin/bash USERNAME
    

    It will be good to make this user an admin, so the user can install software or update the system.

    usermod -aG sudo USERNAME
    

    Set a password for the user

    passwd USERNAME
    

    Now login as the user

    su - USERNAME_HERE
    

    Create a vnc password for this user.

    vncpasswd
    

    Create vnc startup file

    vi ~/.vnc/xstartup
    

    Add

    #!/bin/bash
    
    xrdb $HOME/.Xresources
    autocutsel -fork
    startxfce4 &
    

    Make it executable

    chmod 755 ~/.vnc/xstartup
    

    Auto start VNC Server

    To autostart vncserver on boot, you need to create a service file. You need to do the following as user root.

    vi /etc/systemd/system/[email protected]
    

    Add

    [Unit]
    Description=Start VNC server at startup
    After=syslog.target network.target
    
    [Service]
    Type=forking
    User=USERNAME
    Group=USERNAME
    WorkingDirectory=/home/USERNAME
    
    PIDFile=/home/USERNAME/.vnc/%H:%i.pid
    ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
    ExecStart=/usr/bin/vncserver -depth 24 -geometry 1920x1080  :%i
    ExecStop=/usr/bin/vncserver -kill :%i
    
    [Install]
    WantedBy=multi-user.target
    

    In the above, replace USERNAME with the actual user name you created above.

    Enable the service with

    systemctl enable vncserver@1
    

    Start the VNC server

    systemctl start vncserver@1
    

    Now reboot the server. You should be able to connect to VNC server using SERVER_IP:1

    OPTIONAL: Using RDP instead of VNC

    If you want to use RDP (Windows Remote Desktop) to connect instead of VNC, install xrdp

    apt install -y xrdp
    

    Edit

    vi /etc/xrdp/xrdp.ini
    

    Set value of new_cursors to false.

    new_cursors=false
    

    Change to desktop user

    su - USERNAME
    

    Create file

    vi ~/.xsession
    

    Add following content

    xfce4-session
    export XDG_SESSION_DESKTOP=xubuntu
    export XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/USERNAME:/usr/share
    export XDG_CONFIG_DIRS=/etc/xdg/xfce4:/etc/xdg:/etc/xdg
    

    Enable and restart XRDP

    systemctl enable xrdp
    systemctl restart xrdp
    

    See VNC Server

  • Install HandBrake on Ubuntu 18.04

    HandBreak is an OpenSource Video transcoder available from https://handbrake.fr. It can convert video to various format.

    Latest version of Handbreak available in Ubuntu PPA. To install, enable Handbreak PPA

    add-apt-repository ppa:stebbins/handbrake-releases
    

    Install handbreak with

    apt install handbrake-gtk handbrake-cli
    
  • Install Linux KVM on Ubuntu

    Install Linux KVM on Ubuntu

    Linux KVM is virtualisation software that allow you to create virtual machine under linux. To install on Ubuntu, run

    apt install -y qemu-kvm qemu-utils
    

    Install libvirtd, this allow you to easily create KVM virtual machines and allow remote connection from virt-manager GUI application.

    For Ubuntu 20.04

    apt install -y libvirt-daemon libvirt-daemon-system
    

    For Ubuntu 18.04

    apt install -y libvirt-bin
    

    Enable and start libvirt

    systemctl enable libvirtd
    systemctl start libvirtd
    systemctl is-active libvirtd
    systemctl status libvirtd
    

    At this stage, you should be able to connect to KVM server form your computer using virt-manager.

    You need to create a bridge network interface (“br0”), for this, follow instructions at Linux KVM Bridge network on Ubuntu.

    Downloading ISO

    Before you can setup any VM, you need to download ISO image for the OS. Here i downloaded ISO image for Ubuntu 19.04

    cd /var/lib/libvirt/images
    wget http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu-releases/19.04/ubuntu-19.04-live-server-amd64.iso
    

    Once downloaded, you should be able to select this ISO image in virt-manager when creating a VM.

    See Linux KVM

  • Set default editor in Ubuntu

    To set default editor in Ubuntu/Debian, run

    update-alternatives --config editor
    

    Ubuntu default editor

    See update-alternatives

  • Install drivers on Ubuntu

    Install drivers on Ubuntu

    To install drivers on Ubuntu using command line, run

    boby@sok-01:~$ sudo ubuntu-drivers devices
    == /sys/devices/pci0000:00/0000:00:01.1/0000:01:00.0 ==
    modalias : pci:v000010DEd00001F82sv00001458sd00003FCBbc03sc00i00
    vendor   : NVIDIA Corporation
    driver   : nvidia-driver-430 - distro non-free recommended
    driver   : xserver-xorg-video-nouveau - distro free builtin
    
    boby@sok-01:~$ 
    

    This list all drivers available for your hardware. You can install a driver with apt. In this cuase, i have 2 drivers available

    driver   : nvidia-driver-430 - distro non-free recommended
    driver   : xserver-xorg-video-nouveau - distro free builtin
    

    First driver is recommended by Ubuntu. To install, run

    apt install nvidia-driver-430
    

    Install Driver using Software & Updates

    Start software and updates application.

    Click on Additional Drivers tab. You will see available drivers for your computer.

  • LXD container snapshot and restore

    lxc allow you to take snapshot, restore snapshot of a container.

    Here we create a snapshot, then delete the /etc folder from the container. Now the container is useless. Restore the container from snapshot to get it work again.

    root@UNUSED:~# lxc snapshot my-vm-2 my-vm-2-snap1
    root@UNUSED:~# lxc exec my-vm-2 -- rm -rf /etc
    root@UNUSED:~# lxc exec my-vm-2 -- bash
    I have no name!@my-vm-2:~# ls -l / | grep etc
    I have no name!@my-vm-2:~# exit
    root@UNUSED:~# lxc restore my-vm-2 my-vm-2-snap1
    root@UNUSED:~# lxc exec my-vm-2 -- bash
    root@my-vm-2:~# ls -l / | grep etc
    drwxr-xr-x  89 root   root    4096 Aug 27 07:06 etc
    root@my-vm-2:~# exit
    root@UNUSED:~#
    
  • Install LXD on Ubuntu

    To create LXD containers, run

    lxc launch ubuntu:22.04 VM-NAME-HERE
    lxc launch ubuntu:24.04 VM-NAME-HERE
    lxc launch images:almalinux/8 VM-NAME-HERE
    lxc launch images:almalinux/9 VM-NAME-HERE
    lxc launch images:amazonlinux/2023 VM-NAME-HERE
    lxc launch images:archlinux VM-NAME-HERE
    lxc launch images:centos/9-Stream VM-NAME-HERE
    lxc launch images:debian/11 VM-NAME-HERE
    lxc launch images:debian/12 VM-NAME-HERE
    lxc launch images:fedora/39 VM-NAME-HERE
    lxc launch images:fedora/40 VM-NAME-HERE
    lxc launch images:oracle/8 VM-NAME-HERE
    lxc launch images:oracle/9 VM-NAME-HERE

    LXD is a tool to manage LXC (Linux Containers). lxd allow you to create and manage lightweight Linux containers, it is like docker, but more like an actual virtual machine. LXD is more user-friendly than using LXC directly, has more features like clustering of servers.

    On Ubuntu/Debian, run

    apt install -y lxd lxd-client

    Before you start using lxd, run

    lxd init --auto --storage-backend=dir

    Or

    lxd init

    Just press enter for all questions. Defaults should work. lxd is a demon, only used one time during “lxd init”. After this, you will be using lxc command for everything.

    Example

    root@b24:~# lxd init
    Would you like to use LXD clustering? (yes/no) [default=no]: 
    Do you want to configure a new storage pool? (yes/no) [default=yes]: 
    Name of the new storage pool [default=default]: 
    Name of the storage backend to use (dir, lvm, ceph, btrfs) [default=btrfs]: 
    Create a new BTRFS pool? (yes/no) [default=yes]: 
    Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: 
    Size in GB of the new loop device (1GB minimum) [default=30GB]: 
    Would you like to connect to a MAAS server? (yes/no) [default=no]: 
    Would you like to create a new local network bridge? (yes/no) [default=yes]: 
    What should the new bridge be called? [default=lxdbr0]: 
    What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
    What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: none
    Would you like the LXD server to be available over the network? (yes/no) [default=no]: 
    Would you like stale cached images to be updated automatically? (yes/no) [default=yes] 
    Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: 
    root@b24:~# 

    When it ask for IPv6, I selected “none”, everything else is the default.

    To create a container, run

    lxc launch ubuntu:22.04 vm-1

    Create CentOS container

    lxc launch images:centos/7 vm-2

    Create Debian 10 container

    lxc launch images:debian/10 vm-3

    To list all containers, run

    lxc ls
    lxc list containers

    To stop a VM, run

    lxc stop VM-NAME

    To start VM,

    lxc start VM-NAME

    To see information about a container

    lxc info VM-NAME

    Folders

    /var/snap/lxd/

    To see storage, run

    lxc storage ls

    All containers share the following disk image.

    /var/snap/lxd/common/lxd/disks/default.img