Category: Ubuntu

  • kex_exchange_identification: read: Connection reset by peer

    When connecting to Ubuntu 20.04 server using SSH from a Mac computer, get an error

    kex_exchange_identification: read: Connection reset by peer
    

    On checking the servers log file (/var/log/auth.log), found the following error message

    Jul 23 06:53:34 server sshd[24147]: Unable to negotiate with 17.19.44.24 port 47280: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 [preauth]
    

    To fix this, on the server, edit sshd_config

    vi /etc/ssh/sshd_config
    

    At end of the file, add

    KexAlgorithms +diffie-hellman-group1-sha1
    

    Restart ssh

    systemctl restart ssh
    

    See SSH

  • Ubuntu Screen Recorder

    Ubuntu come with screen recorder, this can be activated with shortcut

    CTRL + ALT + SHIFT + R
    

    By default, it will record for 30 seconds. Video get saved in your home directory (/home/USERNAME) in webm format.

    If you want to increase time, you can run following command

    gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length  TIME_IN_SECONDS_HERE
    

    It is better to set this to 0, this way record never auto stop. You need to manually stop recording with CTRL + ALT + SHIFT + R key combination.

    gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 0
    

    Default value on Ubuntu 20.04 is “uint32 30”

    gsettings

    boby@sok-01:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys max-screencast-length
    uint32 30
    boby@sok-01:~$ gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 0
    boby@sok-01:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys max-screencast-length
    uint32 0
    boby@sok-01:~$ 
    

    See Ubuntu

  • Install LAMP Server on Ubuntu/Debian

    To install LAMP (Apache, MySQL, PHP) on Ubuntu/Debian web server, run

    apt-get install lamp-server^
    

    This use meta package install LAMP. If you want to remove, don’t remove the meta package as it will remove many other required packages. You need to remove packages one by one.

    Related Posts

    Apache

    MySQL

  • Uninstall Time Doctor on Ubuntu

    Uninstall Time Doctor on Ubuntu

    Time Doctor is an application to track time. To uninstall Time Doctor on Ubuntu, run

    sudo /bin/bash -c 'apt purge sfproc; /bin/bash /opt/sfproc/uninstall'
    

    Time doctor run following process

    root@pc8:~# ps aux | grep sfp
    root      7884  0.0  0.1  72848  4316 pts/1    S    09:53   0:00 sudo -H -u training /bin/bash -l -c export DISPLAY=:0; export XAUTHORITY=/run/user/1004/gdm/Xauthority; export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1004/bus,guid=be774defc4c97a1711ff06305e2fb38d; export TD_DEVELOPER=; export XDG_CURRENT_DESKTOP=ubuntu:GNOME; export XDG_SESSION_DESKTOP=ubuntu; export XDG_SESSION_ID=2; cd /home/training; /opt/sfproc/SF/sfproc/3.0.64/sfproc &> /dev/null
    training  7889  0.0  0.0  19992  3148 pts/1    S    09:53   0:00 /bin/bash -l -c export DISPLAY=:0; export XAUTHORITY=/run/user/1004/gdm/Xauthority; export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1004/bus,guid=be774defc4c97a1711ff06305e2fb38d; export TD_DEVELOPER=; export XDG_CURRENT_DESKTOP=ubuntu:GNOME; export XDG_SESSION_DESKTOP=ubuntu; export XDG_SESSION_ID=2; cd /home/training; /opt/sfproc/SF/sfproc/3.0.64/sfproc &> /dev/null
    training  7893  4.4  1.2 1407988 51724 pts/1   SLl  09:53   0:00 /opt/sfproc/SF/sfproc/3.0.64/sfproc
    root      7947  0.0  0.0  21536   976 pts/1    S+   09:54   0:00 grep --color=auto sfp
    root@pc8:~# 
    
  • 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

  • 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