Category: Ubuntu

  • apt show

    apt show command shows information about a package.

    root@ok-vm:~# apt show apache2
    Package: apache2
    Version: 2.4.18-2ubuntu3.5
    Priority: optional
    Section: web
    Origin: Ubuntu
    Maintainer: Ubuntu Developers 
    Original-Maintainer: Debian Apache Maintainers 
    Bugs: https://bugs.launchpad.net/ubuntu/+filebug
    Installed-Size: 501 kB
    Provides: httpd, httpd-cgi
    Pre-Depends: dpkg (>= 1.17.14)
    Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.18-2ubuntu3.5), apache2-utils (>= 2.4), apache2-data (= 2.4.18-2ubuntu3.5)
    Recommends: ssl-cert
    Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw
    Conflicts: apache2.2-bin, apache2.2-common
    Replaces: apache2.2-bin, apache2.2-common
    Homepage: http://httpd.apache.org/
    Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master
    Supported: 5y
    Download-Size: 86.7 kB
    APT-Manual-Installed: yes
    APT-Sources: http://azure.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
    Description: Apache HTTP Server
     The Apache HTTP Server Project's goal is to build a secure, efficient and
     extensible HTTP server as standards-compliant open source software. The
     result has long been the number one web server on the Internet.
     .
     Installing this package results in a full installation, including the
     configuration files, init scripts and support scripts.
    
    N: There is 1 additional record. Please use the '-a' switch to see it
    root@ok-vm:~# 
    

    See apt policy apt

  • apt policy

    apt policy command show information about a package.

    root@ok-vm:~# apt policy  apache2
    apache2:
      Installed: 2.4.18-2ubuntu3.5
      Candidate: 2.4.18-2ubuntu3.5
      Version table:
     *** 2.4.18-2ubuntu3.5 500
            500 http://azure.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
            500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
            100 /var/lib/dpkg/status
         2.4.18-2ubuntu3 500
            500 http://azure.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
    root@ok-vm:~# 
    

    It shows the installed version “Installed: 2.4.18-2ubuntu3.5” and the repo from where it is installed.

    See apt

  • automysqlbackup

    Auto backup all your MySQL databases daily, weekly and monthly.

    To install on Debian/Ubuntu, run

    apt install automysqlbackup -y
    

    To manually backup, run

    automysqlbackup
    

    MySQL backups will be stored in folder

    /var/lib/automysqlbackup/
    

    See backup

  • subprocess installed post-installation script returned error

    When installing software on Ubuntu, i get following error.

    It is likely that 4.5.2-armada375 belongs to a chroot's host
    Building only for 4.9.58-armada375
    Building initial module for 4.9.58-armada375
    Error! Bad return status for module build on kernel: 4.9.58-armada375 (armv7l)
    Consult /var/lib/dkms/spl/0.6.5.6/build/make.log for more information.
    dpkg: error processing package spl-dkms (--configure):
     subprocess installed post-installation script returned error exit status 10
    Setting up dh-python (2.20151103ubuntu1) ...
    Processing triggers for libc-bin (2.23-0ubuntu3) ...
    Errors were encountered while processing:
     spl-dkms
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    To fix this, run

    rm /var/lib/dpkg/info/PACKAGE_NAME_HERE.*
    dpkg --configure -a
    apt update
    

    Replace PACKAGE_NAME_HERE with actual package that fail. In this cause spl-dkms.

    root@ns539260:/var/lib/dpkg/info# ls -l | grep spl
    -rw-r--r-- 1 root root   11811 Nov 22 07:41 spl-dkms.list
    -rw-r--r-- 1 root root   19548 Apr  7  2016 spl-dkms.md5sums
    -rwxr-xr-x 1 root root     891 Apr  7  2016 spl-dkms.postinst
    -rwxr-xr-x 1 root root     312 Apr  7  2016 spl-dkms.prerm
    root@ns539260:/var/lib/dpkg/info# rm spl-dkms.*
    

    See apt

  • update-alternatives

    Set default editor in Ubuntu

    To change vi editor run

    root@backup:~# update-alternatives --config vi
    There are 2 choices for the alternative vi (providing /usr/bin/vi).
    
      Selection    Path                Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/vim.basic   30        auto mode
      1            /usr/bin/vim.basic   30        manual mode
      2            /usr/bin/vim.tiny    10        manual mode
    
    Press  to keep the current choice[*], or type selection number: 
    root@backup:~# 
    

    To display current vi config, run

    root@backup:~# update-alternatives --display vi
    vi - auto mode
      link best version is /usr/bin/vim.basic
      link currently points to /usr/bin/vim.basic
      link vi is /usr/bin/vi
      slave vi.1.gz is /usr/share/man/man1/vi.1.gz
      slave vi.fr.1.gz is /usr/share/man/fr/man1/vi.1.gz
      slave vi.it.1.gz is /usr/share/man/it/man1/vi.1.gz
      slave vi.ja.1.gz is /usr/share/man/ja/man1/vi.1.gz
      slave vi.pl.1.gz is /usr/share/man/pl/man1/vi.1.gz
      slave vi.ru.1.gz is /usr/share/man/ru/man1/vi.1.gz
    /usr/bin/vim.basic - priority 30
      slave vi.1.gz: /usr/share/man/man1/vim.1.gz
      slave vi.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
      slave vi.it.1.gz: /usr/share/man/it/man1/vim.1.gz
      slave vi.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz
      slave vi.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz
      slave vi.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz
    /usr/bin/vim.tiny - priority 10
      slave vi.1.gz: /usr/share/man/man1/vim.1.gz
      slave vi.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
      slave vi.it.1.gz: /usr/share/man/it/man1/vim.1.gz
      slave vi.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz
      slave vi.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz
      slave vi.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz
    root@backup:~# 
    
  • apt doesn’t support architecture i386

    After adding facebook hhvm repository on Ubuntu 16.04, i get following error when running “apt update” command.

    root@backup:~# apt-get update
    Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
    Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease                                                                                                       
    Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]                                                                                      
    Hit:4 http://ftp.osuosl.org/pub/mariadb/repo/10.1/ubuntu xenial InRelease                                                                                        
    Ign:5 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 InRelease                                                                                        
    Get:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]                                                                                    
    Hit:7 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease                   
    Hit:8 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release             
    Ign:10 https://pkg.jenkins.io/debian-stable binary/ InRelease
    Hit:11 https://download.docker.com/linux/ubuntu xenial InRelease
    Hit:12 https://pkg.jenkins.io/debian-stable binary/ Release
    Get:13 https://dl.hhvm.com/ubuntu xenial InRelease [2,411 B]
    Get:15 https://dl.hhvm.com/ubuntu xenial/main amd64 Packages [2,244 B]
    Fetched 311 kB in 1s (283 kB/s)
    Reading package lists... Done
    N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://dl.hhvm.com/ubuntu xenial InRelease' doesn't support architecture 'i386'
    root@backup:~#
    

    This is fixed by editing

    vi /etc/apt/sources.list
    

    Find

    deb https://dl.hhvm.com/ubuntu xenial main
    

    Replace with

    deb [arch=amd64] https://dl.hhvm.com/ubuntu xenial main
    
  • add-apt-repository

    add-apt-repository command can be used to add repository in ubuntu.

    To install, run

    apt-get install software-properties-common python-software-properties
    

    Example

    apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94
    add-apt-repository https://dl.hhvm.com/ubuntu
    
  • apt

    List all Dependencies for a package.

    apt depends PKG_NAME

    If you don’t want to upgrade a package, you can use apt-mark command to hold it, the package won’t be upgraded

    apt-mark hold 5.15.0-107-generic

    If you want to remove the hold and allow the package to be upgraded, use

    apt-mark unhold 5.15.0-107-generic

    Errors

    This website allow you to generate /etc/apt/sources.list file for Ubuntu/Debian.

    https://repogen.simplylinux.ch

    This is helpful when you need to recreate your repo file.

    Errors

    apt fail after MariaDB to MySQL change

  • huawei e8231 usb modeswitch

    By default, device work in Mass Storage mode

    root@fwhlin:~ # lsusb | grep Huawei
    Bus 009 Device 007: ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
    root@fwhlin:~ # 
    

    Create file

    vi /etc/usb_modeswitch.d/12d1:1f01
    

    With following content

    root@fwhlin:~ # cat /etc/usb_modeswitch.d/12d1:1f01
    # Huawei E3531s-2 - switch to modem mode instead of HiLink CDC-Ether mode
    TargetVendor=0x12d1
    TargetProduct=0x1f01
    
    # switch to 12d1:1001 (modem mode, 3 virtual serial ports)
    #MessageContent="55534243123456780000000000000011062000000100000000000000000000"
    
    # switch to 12d1:14dc (default HiLink CDC-Ether mode)
    MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
    
    # switch to 12d1:1442 (debug mode with 2 virtual serial ports)
    # MessageContent="55534243000000000000000000000011060000000000000000000000000000"
    
    root@fwhlin:~ # 
    

    To switch to Modem Mode, run

    usb_modeswitch -I -W -c /etc/usb_modeswitch.d/12d1\:1f01
    

    If it worked, device will change to modem mode

    root@fwhlin:~ # lsusb | grep Hu
    Bus 009 Device 003: ID 12d1:14dc Huawei Technologies Co., Ltd. 
    root@fwhlin:~ # 
    

    Notice it changed name, also device ID changed to 14dc.

    ifconfig will list a new network interface usb0

    usb0      Link encap:Ethernet  HWaddr 9a:82:a1:91:20:32  
              inet6 addr: fe80::9882:a1ff:fe91:2032/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:236 errors:0 dropped:0 overruns:0 frame:0
              TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:111083 (111.0 KB)  TX bytes:15412 (15.4 KB)
    
  • getting huawei e8231 work on ubuntu 14.04

    After connecting, i get following in lsusb

    root@fwhlin:~ # lsusb | grep 12d1
    Bus 009 Device 004: ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
    root@fwhlin:~ # 
    

    It says “Mass storage mode”. If you check demesg, you will see

    [ 2385.775523] usb 9-2: New USB device found, idVendor=12d1, idProduct=1f01
    [ 2385.775527] usb 9-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 2385.775529] usb 9-2: Product: HUAWEI Mobile
    [ 2385.775531] usb 9-2: Manufacturer: HUAWEI
    [ 2385.775532] usb 9-2: SerialNumber: FFFFFFFFFFFFFFFF
    [ 2385.837882] usb-storage 9-2:1.0: USB Mass Storage device detected
    [ 2385.838108] scsi15 : usb-storage 9-2:1.0
    [ 2386.858462] scsi 15:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
    [ 2386.859826] sr1: scsi-1 drive
    [ 2386.859946] sr 15:0:0:0: Attached scsi CD-ROM sr1
    

    Last line says, device mounted as “/dev/sr1”

    root@fwhlin:~ # df -h | grep sr
    /dev/sr1        4.3M  4.3M     0 100% /media/boby/MobileWiFi
    root@fwhlin:~ # 
    

    Changing Device Mode to Modem

    I found some information about the device in file

    sudo -s
    cd /usr/share/usb_modeswitch
    tar zxvf configPack.tar.gz
    
    root@fwhlin:~ # cat /usr/share/usb_modeswitch/12d1:1f01
    # Huawei E353 (3.se) and others
    TargetVendor=0x12d1
    TargetProductList="14db,14dc"
    MessageContent="55534243123456780000000000000011062000000101000100000000000000"
    NoDriverLoading=1
    root@fwhlin:~ # 
    

    It says device can operate as products “14db” and “14dc”.

    I tried changing device mode to product id 14db, it did not work, so tried 14dc and it worked.

    usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14dc -M "55534243123456780000000000000011062000000101000100000000000000"
    
    root@fwhlin:~ # usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14dc -M "55534243123456780000000000000011062000000101000100000000000000"
    Look for target devices ...
     No devices in target mode or class found
    Look for default devices ...
       product ID matched
     Found devices in default mode (1)
    Access device 002 on bus 009
    Current configuration number is 1
    Use interface number 0
    Use endpoints 0x01 (out) and 0x81 (in)
    
    USB description data (for identification)
    -------------------------
    Manufacturer: HUAWEI
         Product: HUAWEI Mobile
      Serial No.: FFFFFFFFFFFFFFFF
    -------------------------
    Looking for active driver ...
     No active driver found. Detached before or never attached
    Set up interface 0
    Use endpoint 0x01 for message sending ...
    Trying to send message 1 to endpoint 0x01 ...
     OK, message successfully sent
    Reset response endpoint 0x81
    Reset message endpoint 0x01
    -> Run lsusb to note any changes. Bye!
    
    root@fwhlin:~ #
    

    Now “ifconfig” shows usb0.

    root@fwhlin:~ # ifconfig
    ...
    ...
    ...
    usb0      Link encap:Ethernet  HWaddr be:69:7c:b1:a3:b6  
              inet addr:192.168.8.100  Bcast:192.168.8.255  Mask:255.255.255.0
              inet6 addr: fe80::bc69:7cff:feb1:a3b6/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:15 errors:0 dropped:0 overruns:0 frame:0
              TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:6315 (6.3 KB)  TX bytes:8138 (8.1 KB)
    
    root@fwhlin:~ # 
    

    If you check “lsusb”, now device have different product id.

    root@fwhlin:~ # lsusb | grep 12d1
    Bus 009 Device 003: ID 12d1:14dc Huawei Technologies Co., Ltd. 
    root@fwhlin:~ # 
    

    Connecting To Internet

    You will need to disable eth0 or all traffic will be routed through it by default.

    suo ifconfig eth0 down
    
    root@fwhlin:~ # curl http://iptools.bizhat.com/ipv4.php
    59.98.137.87
    root@fwhlin:~ # sudo ifconfig eth0 down
    root@fwhlin:~ # curl http://iptools.bizhat.com/ipv4.php
    106.77.164.191
    root@fwhlin:~ #
    
  • Enable remote desktop in xubuntu

    Enable remote desktop in xubuntu

    Install vino

    sudo apt-get install vino
    

    install vino

    Configure Vino

    Configure vino, run

    vino-preferences
    

    xubuntu vino preferences

    Start vino on boot

    XFCE settings > Session and Startup > Add

    xubuntu xfce startup

    xubuntu xfce auto start application

    Name: vino
    Description: vino desktop sharing
    Command: /usr/lib/vino/vino-server
    

    xfce start application on system boot

    Now restart the computer.

    See Ubuntu