Category: Linux

  • xinetd

    To run xinetd in forground in debug mode, run

    /usr/sbin/xinetd -d -dontfork
    
  • Displaying /proc/PID/cmdline with space

    Displaying /proc/PID/cmdline with space

    On linux, the file /proc/PID/cmdline shows the command line for the process. If you check content of this file, you will see the command, but arguments are not seperated by space.

    To display the command line with space, run

    cat /proc/PID/cmdline | tr '\000' ' '
    

    Or

    cat /proc/PID/cmdline  | xargs -0 echo
    

    Example

    To display environ file, run

    cat environ  | xargs -0 -L1  echo
    
  • apt-key keyserver receive failed: No dirmngr

    When running apt-key command, i get following error.

    root@ip-172-31-46-9:~# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
    Executing: /tmp/apt-key-gpghome.MYmMoDt7Sv/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
    gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
    gpg: connecting dirmngr at '/run/user/0/gnupg/d.ar6ctd7ngpsiegqaseo7cgyr/S.dirmngr' failed: No such file or directory
    gpg: keyserver receive failed: No dirmngr
    root@ip-172-31-46-9:~# 

    To fix this, run

    apt install dirmngr
  • Install MongoDB 4 on Debian 9

    You can see detailed instruction on how to install on MongoDB web site.

    First add key

    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
    

    For Debian 8, run

    echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/4.0 main" > /etc/apt/sources.list.d/mongodb-org-4.0.list
    

    For Debian 9, run

    echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" > /etc/apt/sources.list.d/mongodb-org-4.0.list
    

    Now install mongoDB with

    apt-get update
    apt-get install -y mongodb-org
    

    Once installed, you can check version with

    root@ip-172-31-25-155:~# mongod --version
    db version v4.0.4
    git version: f288a3bdf201007f3693c58e140056adf8b04839
    OpenSSL version: OpenSSL 1.1.0f  25 May 2017
    allocator: tcmalloc
    modules: none
    build environment:
        distmod: debian92
        distarch: x86_64
        target_arch: x86_64
    root@ip-172-31-25-155:~# 
    

    Enable MongoDB start on boot

    systemctl enable mongod
    

    To start/stop mongodb

    systemctl start mongod
    systemctl stop mongod
    
  • Fix yum duplicate packages

    On a CentOS server, when running

    yum update
    

    It failed with following error

    acl-2.2.51-14.el7.x86_64 is a duplicate with acl-2.2.51-12.el7.x86_64
    alt-libcurlssl-7.60.0-1.el7.x86_64 is a duplicate with alt-libcurlssl-7.54.0-8.el7.cloudlinux.x86_64
    alt-php-config-1-29.1.el7.noarch is a duplicate with alt-php-config-1-27.el7.noarch
    alt-php44-4.4.9-88.el7.x86_64 is a duplicate with alt-php44-4.4.9-81.el7.x86_64
    alt-php44-bcmath-4.4.9-88.el7.x86_64 is a duplicate with alt-php44-bcmath-4.4.9-81.el7.x86_64
    

    https://gist.github.com/serverok/c0853120baff8848054cfb598e389c3a

    This is because previous “yum update” failed for some reason after package install. So no cleanup was done.

    To fix, you need to use package-cleanup command.

    yum install yum-utils
    

    To list all duplicate packages, run

    package-cleanup --dupes
    

    To remove all duplicate packages, run

    package-cleanup --cleandupes
    

    Now do a yum update

    yum update
    

    This will update your system and install any missing packages.

    To verify if there any problem, run

    package-cleanup --problems
    

    If this does not fix, try yum fix duplicate package error

    See yum

  • Making POST request from curl

    Here is an example POST request using curl

    curl -d "param1=value1¶m2=value2" -X POST http://sok.test/post.php
    

    Sending JSON string

    curl  http://video.com/like -X POST --data '{"like":"1","media_id":"781","time_start":"100:36:19.584"}'
    

    Post a variable

    curl  URL_HERE -X POST --data 'badSSN=111111111'
    
  • fsck

    To check hard disk, run

    fsck.ext4 /dev/sda1

    Auto Repair file system

    By default fsck will ask you what to do when it find any error. When you have many errors, pressing y for each error is time consuming. It is better use -a or -y option for auto repair.

    fsck -y /dev/sda1

    Delayed block allocation failed for inode

  • centovacast

    Install Paid SSL on Centova Cast
    Install LetsEncrypt Free SSL on Centova Cast
    CentovaCast Enable SSL on icecast
    CentovaCast Enable SSL for shoutcast
    Manually run icecast on CentovaCast server
    Upgrade CentovaCast
    CentovaCast change MySQL password

    mp3 files stored in folder

    /usr/local/centovacast/var/vhosts/USER/var/spool/media/
    

    Login url

    http://IP_ADDR_OR_DOMAIN:2199
    

    When user connect with FTP, he will see files from folder /usr/local/centovacast/var/vhosts/USER/var/spool/

  • ISPConfig 3 configuration files

    ISPConfig 3 configuration files are are located in folder

    /usr/local/ispconfig/interface/lib/config.inc.php
    /usr/local/ispconfig/server/lib/config.inc.php
    /usr/local/ispconfig/server/lib/mysql_clientdb.conf
    

    DocumentRoot

    /usr/local/ispconfig/interface/web/
    

    Config file for webmail/phpmyadmin

    /etc/nginx/sites-available/000-apps.vhost
    

    Config for ispconfig web interface

    /etc/nginx/sites-available/ispconfig.vhost
    
  • Odoo apt signatures couldn’t be verified

    When updating apt on Ubuntu server, i get following error

    root@ip-172-31-25-25:/home/ubuntu# apt-get update 
    Hit:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
    Hit:2 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease                                                         
    Hit:3 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease                                                       
    Ign:4 http://nightly.odoo.com/9.0/nightly/deb ./ InRelease                                                       
    Get:5 http://nightly.odoo.com/9.0/nightly/deb ./ Release [1186 B]                      
    Get:6 http://nightly.odoo.com/9.0/nightly/deb ./ Release.gpg [819 B]
    Ign:6 http://nightly.odoo.com/9.0/nightly/deb ./ Release.gpg
    Get:7 http://nightly.odoo.com/9.0/nightly/deb ./ Packages [1790 B]
    Hit:8 http://security.ubuntu.com/ubuntu xenial-security InRelease
    Fetched 3795 B in 2s (1736 B/s)
    Reading package lists... Done
    W: GPG error: http://nightly.odoo.com/9.0/nightly/deb ./ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DEF2A2198183CBB5
    W: The repository 'http://nightly.odoo.com/9.0/nightly/deb ./ Release' is not signed.
    N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    root@ip-172-31-25-25:/home/ubuntu# 
    

    To fix, run

    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DEF2A2198183CBB5