Category: Linux

  • Autostart icecast using systemd

    To autostart icecast using systemd, create a unit file

    vi /etc/systemd/system/icecast.service
    

    Add following content

    [Unit]
    Description=Icecast Network Audio Streaming Server
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/local/bin/icecast -c /etc/icecast/icecast.xml
    ExecReload=/bin/kill -HUP $MAINPID
    User=icecast
    Group=icecast
    WorkingDirectory=/home/icecast/
    
    [Install]
    WantedBy=multi-user.target

    Enable icecast to start on boot with

    systemctl enable icecast

    To start/stop/restart icecast, use

    systemctl start icecast
    systemctl stop icecast
    systemctl restart icecast
  • configure: error: must have Ogg Vorbis v1.0 or above installed

    when installing icecast from the source on the CentOS 7 server, I get error

    checking for libogg... not found
    checking for libvorbis... configure: error: must have Ogg Vorbis v1.0 or above installed

    To fix the error, install libvorbis-devel

    yum install -y libvorbis-devel

    See Errors

  • How to install icecast KH on CentOS 7 Server

    Download latest source code for IceCast KH server from

    https://github.com/karlheyes/icecast-kh/releases

    At the time of writing this post, latest version is 2.4.0-kh15

    cd /usr/local/src
    wget https://github.com/karlheyes/icecast-kh/archive/icecast-2.4.0-kh15.tar.gz
    tar -zxf icecast-2.4.0-kh15.tar.gz
    cd icecast-kh-icecast-2.4.0-kh15
    ./configure
    make CFLAGS="-D_XOPEN_SOURCE=600"
    make install
    

    If you get error related to “XSLT configuration could not be found”, see configure: error: XSLT configuration could not be found

    You need a non root user to run icecast, create a user

    useradd -m -s /bin/bash icecast
    

    Copy the sample conif file

    mkdir /etc/icecast
    cp /usr/local/src/icecast-kh-icecast-2.4.0-kh13/examples/icecast_minimal.xml /etc/icecast/
    chown -R icecast:icecast /etc/icecast/
    cp -R /usr/local/src/icecast-kh-icecast-2.4.0-kh13/admin/ /home/icecast/admin/
    cp -R /usr/local/src/icecast-kh-icecast-2.4.0-kh13/web/ /home/icecast/web/
    chown -R icecast:icecast /home/icecast/admin/
    chown -R icecast:icecast /home/icecast/web/
    

    Switch to user icecast

    su - icecast
    

    Create folders for logs

    mkdir /home/icecast/logs
    

    To start icecast, run

    icecast -c /etc/icecast/icecast.xml
    

    Edit icecast.xml, set the password and ports as required.

    To autostart icecast on server boot, check Autostart icecast using systemd.

    See icecast

  • Install PHP 5.6 on CentOS 7

    To install PHP 5.6 on CentOS 7, enable EPEL repo and remi repo

    yum install epel-release -y
    rpm -ivh https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    

    Install yum-utils and enable remi-php56 repo

    yum install yum-utils
    yum-config-manager --enable remi-php56
    

    Install PHP 5.6 with

    yum install -y php php-bcmath php-cli php-common php-devel php-gd \
        php-imap php-intl php-json php-ldap php-lz4 php-mbstring php-mysqlnd \
        php-soap php-intl php-opcache php-xml php-pdo
    
  • configure: error: XSLT configuration could not be found

    When installing a software from source i get error

    configure: error: XSLT configuration could not be found
    

    To fix the error install run

    CentOS/RHEL

    yum install -y libxslt-devel
    

    See Errors

  • How to increase /tmp partition size

    On a Linux server /tmp partition was only 1 GB, it get full at times.

    Server had following in its /etc/fstab file

    [root@imeicheck-2020 ~]# cat /etc/fstab 
    UUID=c0f46bb1-c0bc-4199-95d6-551d03c12a0a /                       xfs     defaults        1 1
    /var/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0
    /tmp /var/tmp none bind 0 0
    [root@imeicheck-2020 ~]#
    

    Currenly file /var/.tempdisk is mounted as /tmp.

    So i created a new file with 4 GB size

    dd if=/dev/zero of=/var/sok_tmp bs=1M count=4096
    

    Format it as ext4 file system

    mkfs -t ext4 /var/sok_tmp
    

    Before i swith /tmp to newly created disk, i need to copy content of current /tmp to it. For this i mount the new disk as /tmp2

    mkdir /tmp2
    mount -o loop /var/sok_tmp /tmp2
    rsync -avzP /tmp/ /tmp2/
    

    Now you have all files of /tmp in /tmp2, edit /etc/fstab

    vi /etc/fstab
    

    Find entry for current /tmp partition

    /var/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0
    

    Replace it with new file you created

    /var/sok_tmp /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0
    

    Reboot the server. You will have 4 GB /tmp partition now.

  • apt The method driver /usr/lib/apt/methods/https could not be found

    When running apt update on a Debian server, i get error

    root@shop:~# apt-get update
    E: The method driver /usr/lib/apt/methods/https could not be found.
    N: Is the package apt-transport-https installed?
    root@shop:~# 
    

    apt https error

    To fix the error, run

    apt-get install apt-transport-https ca-certificates
    

    See apt

  • uname

    List Kernel Full details

    boby@hon-pc-01:~ $ uname -a
    Linux hon-pc-01 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    boby@hon-pc-01:~ $ 
    

    List Architecture

    boby@hon-pc-01:~ $ uname -m
    x86_64
    boby@hon-pc-01:~ $ 
    

    Show Kernel Version

    boby@hon-pc-01:~ $ uname -r
    4.4.0-53-generic
    boby@hon-pc-01:~ $ 
    

    See Linux Commands

  • Lock User Account in Linux

    To lock a Linux User account, run

    usermod -L USER_NAME_HERE
    

    You can verify the account is locked with command

    passwd --status USER_NAME_HERE
    

    Example

    Lock Linux User Account usermod

    See usermod

  • VestaCP disable Backups

    VestaCP disable Backups

    In VestaCP, each packages have option to specify how many backups it can take. First you need to click on packages, then change number of backups allowed for each package.

    VestaCP disable backup

    If backups allowed is more than 0, set it to 0.

    Users are created with these Packages. For all existing users, you need to manually edit file

    /usr/local/vesta/data/users/USERNAME_HERE/user.conf
    

    change value for backup to 0.

    If you have many users, instead o editing one by one, you can use following bash script.

    #!/bin/bash
    
    FILES=$(find /usr/local/vesta/data/users/ -name "user.conf")
    
    for USER_FILE in $FILES
    do
        echo "Processing ${USER_FILE}"
        sed -i "s/^BACKUPS=.*$/BACKUPS='0'/g" $USER_FILE
        sed -i "s/^U_BACKUPS=.*$/U_BACKUPS='0'/g" $USER_FILE
    done
    

    See VestaCP

  • wget force IPv4/6 download

    If your server support both IPv4 and IPv6 and you need to force download a file using IPv4, you can use

    wget -4 URL_HERE
    

    To force IPv6 connection, use

    wget -6 URL_HERE
    

    Example

    [root@li2136-233 ~]# wget -4 https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    --2020-09-22 04:45:30--  https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    Resolving rpms.remirepo.net (rpms.remirepo.net)... 195.154.241.117
    Connecting to rpms.remirepo.net (rpms.remirepo.net)|195.154.241.117|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 20732 (20K) [application/x-rpm]
    Saving to: ‘remi-release-7.rpm’
    
    100%[==================================================================================================================================================================>] 20,732      74.2KB/s   in 0.3s   
    
    2020-09-22 04:45:32 (74.2 KB/s) - ‘remi-release-7.rpm’ saved [20732/20732]
    
    [root@li2136-233 ~]# 
    

    from wget help, here are the options

    wget IPv4 connection

    See wget