Category: Linux

  • iptables -F lock me out

    After i type

    iptables -F
    

    server goes down. Can’t connect to web or ssh, seems all connection is locked by iptables.

    SOLUTION

    This is because the chain policy for the firewall input chain was set to DROP

    check with “iptables –list” you will see “Chain INPUT (policy DROP)”.

    [root@server52 ~]# iptables -L |grep Chain
    Chain INPUT (policy DROP)
    Chain FORWARD (policy DROP)
    Chain OUTPUT (policy DROP)
    Chain GALLOW (2 references)
    Chain INVALID (2 references)
    Chain INVDROP (10 references)
    Chain LOGDROPIN (1 references)
    Chain LOGDROPOUT (1 references)
    [root@server52 ~]# 
    

    If this is the case, before you run a flush, ensure you set the input chain policy to ACCEPT by running.

    iptables -P INPUT ACCEPT
    iptables -P FORWARD ACCEPT
    iptables -P OUTPUT ACCEPT
    iptables -F
    service iptables save
    

    Then you will be able to run iptables -F without any problem.

    When you try modifying firewall rules, better set a cronjob with following commands that run every 5 or 10 minutes, so if you get locked out, you will be able to get access again after the cronjob runs.

    iptables -P INPUT ACCEPT
    iptables -P FORWARD ACCEPT
    iptables -P OUTPUT ACCEPT
    iptables -F
    

    See iptables

  • Install vnc server on CentOS 5

    NOTE: CentOS 5 reached its End of Life on March 31, 2017. For installing VNC desktop on CentOS 7, see Install Xfce VNC remote desktop on CentOS 7

    Install GUI on Sever

    To find available desktop environments

    yum grouplist
    

    To install gnome

    yum groupinstall "GNOME Desktop Environment"
    

    For KDE

    yum groupinstall "KDE (K Desktop Environment)"
    

    For XFCE, install

    yum groupinstall "XFCE"
    

    XFCE file size in fedora 12 Total download size: 105 M, Installed size: 363 M

    Install VNC Server

    yum install vnc vnc-server
    

    Start VNC Server

    [root@pc7 ~]# vncserver
    
    You will require a password to access your desktops.
    
    Password:
    Verify:
    xauth:  creating new authority file /root/.Xauthority
    
    New 'pc7.localdomain:1 (root)' desktop is pc7.localdomain:1
    
    Creating default startup script /root/.vnc/xstartup
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/pc7.localdomain:1.log
    
    [root@pc7 ~]#
    

    Now stop vnc server with

    pkill -9 vnc
    rm -rf /tmp/.X*
    

    Set Password for VNC Server

    vncpasswd /root/.vnc/passwd
    
    [root@pc7 ~]# vncpasswd /root/.vnc/passwd
    Password:
    Verify:
    [root@pc7 ~]#
    

    Edit xstartup

    vi  /root/.vnc/xstartup
    

    Find

    twm &
    

    Replace it with

    For Gnome

    gnome-session &
    

    For XFCE

    startxfce4 &
    

    For KDE

    startkde &
    

    For FVWM2

    fvwm2 &
    

    After change, it will look like

    [root@pc7 ~]# cat /root/.vnc/xstartup
    #!/bin/sh
    
    vncconfig -iconic &
    # Uncomment the following two lines for normal desktop:
    # unset SESSION_MANAGER
    # exec /etc/X11/xinit/xinitrc
    
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    gnome-session &
    [root@pc7 ~]#
    

    Create VNC Users

    vi /etc/sysconfig/vncservers
    

    Add

    VNCSERVERS="1:flashwebhost"
    

    Start VNC Server

    [root@pc7 ~]# vncserver
    
    New 'pc7.localdomain:1 (root)' desktop is pc7.localdomain:1
    
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/pc7.localdomain:1.log
    
    [root@pc7 ~]#
    

    Connecting

    Start tightVNC Viewer, connect to IP-ADDR:1 to connect as user root.

    See VNC server

  • Wrong JPEG library version: library is 62, caller expects 80

    This is caused by multiple versions of libjpeg installed on the server.

    Check for libjpeg in library folders.

    Lib folders can be find by checking /etc/ld.so.conf

    root@serv02 [/usr/lib]# cat /etc/ld.so.conf
    include ld.so.conf.d/*.conf
    /usr/lib64/
    /usr/local/lib
    /usr/lib
    root@serv02 [/usr/lib]# cd /usr/lib64/
    

    Check version of libjpeg installed

    cd /usr/lib64/
    ls -la | grep jpeg
    
    cd /usr/local/lib
    ls -la | grep jpeg
    
    cd /usr/lib
    ls -la | grep jpeg
     

    Folder /usr/lib64/ have libjpeg.so.62.0.0 installed.

    root@serv02 [/usr/lib]# cd /usr/lib64/
    root@serv02 [/usr/lib64]# ls -la | grep jpeg
    lrwxrwxrwx  1 root root       17 Mar  8 09:54 libjpeg.so -> libjpeg.so.62.0.0*
    lrwxrwxrwx  1 root root       17 Mar  8 09:14 libjpeg.so.62 -> libjpeg.so.62.0.0*
    -rwxr-xr-x  1 root root   138936 Jan  6  2007 libjpeg.so.62.0.0*
    root@serv02 [/usr/lib64]#
    

    Folder /usr/local/lib have libjpeg.so.8.3.0 installed

    root@serv02 [/usr/local/lib]# ls -la | grep jpeg
    drwxr-xr-x  4 uploadin users    12288 Mar  9 11:43 jpeg-8c/
    -rw-r--r--  1 root     root    986681 Jan 16 10:22 jpegsrc.v8c.tar.gz
    -rw-r--r--  1 root     root   1759458 Mar  9 11:43 libjpeg.a
    -rwxr-xr-x  1 root     root       916 Mar  9 11:43 libjpeg.la*
    lrwxrwxrwx  1 root     root        16 Mar  9 11:43 libjpeg.so -> libjpeg.so.8.3.0*
    lrwxrwxrwx  1 root     root        16 Mar  8 15:36 libjpeg.so.7 -> libjpeg.so.7.0.0*
    -rwxr-xr-x  1 root     root    335442 Mar  8 15:36 libjpeg.so.7.0.0*
    lrwxrwxrwx  1 root     root        16 Mar  9 11:43 libjpeg.so.8 -> libjpeg.so.8.3.0*
    -rwxr-xr-x  1 root     root    968498 Mar  9 11:43 libjpeg.so.8.3.0*
    root@serv02 [/usr/local/lib]#
    

    To fix, deleted all libjpeg.so.62.0.0 files

    cd /usr/lib64/
    rm -f libjpeg.so.*
    

    Now create a symlink

    cd /usr/lib64/
    ln -s /usr/local/lib/libjpeg.so.8.3.0 libjpeg.so.62
    

    Check what provides libjpeg

    yum whatprovides "*/libjpeg.so.62.0.0"
    

    See if libjpeg installed

    rpm -qa | grep libjpeg
    
    root@serv02 [/usr/local/lib]# rpm -qa | grep libjpeg
    libjpeg-6b-37
    libjpeg-devel-6b-37
    libjpeg-6b-37
    root@serv02 [/usr/local/lib]#
    

    Uninstall libjpeg

    rpm -e --nodeps libjpeg-6b-37 libjpeg-devel-6b-37 libjpeg-6b-37
    

    Edit /etc/yum.conf

    Disable auto updating libjpeg by adding

    libjpeg*
    

    in exclude line.

    See Errors

  • Start shoutcast on boot

    This method is for CentOS 6. On newer systems, you may need to use systemd or enable rc-local service for /etc/rc.local to work./

    vi /home/shoutcast/shoutcast.sh
    

    Add

    #!/bin/bash
    
    killall sc_serv
    killall sc_trans_linux
    cd /home/shoutcast/
    ./sc_serv  >/dev/null &
    cd /home/shoutcast/sc_trans_040
    ./sc_trans_linux >/dev/null &
    
    

    Set permission

    chmod 755 /home/shoutcast/shoutcast.sh
    

    To start on boot, we add it to /etc/rc.local

    vi /etc/rc.local
    

    At the end of the file add as new line

    /home/shoutcast/shoutcast.sh
    

    See Shoutcast

  • Shoutcast sc trans

    sc_trans can play list of mp3 files to shoutcast server so your online radio station will be online even if you are not online.

    Install sc_trans

    cd /home
    mkdir shoutcast
    cd shoutcast
    wget http://yp.shoutcast.com/downloads/sc_trans_posix_040.tgz
    tar -zxvf sc_trans_posix_040.tgz
    cd sc_trans_040
    

    Create Play List of mp3 Files

    Upload your MP3 files to folder

    /home/shoutcast/sc_trans_040/mp3

    To create a play list, run

    find ./mp3 -type f -name "*.mp3" > playlist.lst
    

    Edit sc_trans.conf

    Find

    PlaylistFile=example.lst
    

    Replace With

    PlaylistFile=playlist.lst
    

    Find

    ServerIP=myserver.com
    

    Replace with IP of server on which you run shoutcast server.

    ServerIP=server28.hosthat.com
    

    Find

    ServerPort=8000
    

    8000 is default shoutcast server port. Change it if you use non default port.

    Find

    Password=
    

    Set the password you set in shoutcast server in Password= line.

    Start sc_trans

    Run

    ./sc_trans_linux
    

    Listening to Online Radio

    In Windows Media player, file > open url, enter

    http://server28.hosthat.com:8000

    start playing the songs.

    See shoutcast

  • Install shoutcast server

    Download linux version from site

    http://www.shoutcast.com/download-files

    cd /home
    mkdir shoutcast
    cd shoutcast
    wget http://yp.shoutcast.com/downloads/sc1-9-8/sc_serv_1.9.8_Linux.tar.gz
    tar -zxvf sc_serv_1.9.8_Linux.tar.gz
    

    Now edit sc_serv.conf

    vi sc_serv.conf
    

    Find

    Password=changeme
    

    Replace changeme with secure password.

    Other important options are

    MaxUser
    PortBase
    

    To start, run

    ./sc_serv 
    

    To start in background, run

    ./sc_serv &
    

    After you run, you will see

    [root@server28 shoutcast]# ./sc_serv
    *******************************************************************************
    ** SHOUTcast Distributed Network Audio Server
    ** Copyright (C) 1998-2004 Nullsoft, Inc.  All Rights Reserved.
    ** Use "sc_serv filename.ini" to specify an ini file.
    *******************************************************************************
    
    Event log:
    <08/14/09@18:37:38> [SHOUTcast] DNAS/Linux v1.9.8 (Feb 28 2007) starting up...
    <08/14/09@18:37:38> [main] pid: 27910
    <08/14/09@18:37:38> [main] loaded config from sc_serv.conf
    <08/14/09@18:37:38> [main] initializing (usermax:32 portbase:8000)...
    <08/14/09@18:37:38> [main] No ban file found (sc_serv.ban)
    <08/14/09@18:37:38> [main] No rip file found (sc_serv.rip)
    <08/14/09@18:37:38> [main] opening source socket
    <08/14/09@18:37:38> [main] source thread starting
    <08/14/09@18:37:38> [main] opening client socket
    <08/14/09@18:37:38> [source] listening for connection on port 8001
    <08/14/09@18:37:38> [main] Client Stream thread [0] starting
    <08/14/09@18:37:38> [main] client main thread starting
    <08/14/09@18:38:05> [dest: 59.98.136.119] server unavailable, disconnecting
    <08/14/09@18:38:06> [dest: 59.98.136.119] Invalid resource request(/favicon.ico)
    <08/14/09@18:39:45> [sleeping] 0 listeners (0 unique)
    

    By default shoutcast run on port 8000.

    If you go to

    http://server28.hosthat.com:8000/

    You will get

    ICY 401 Service Unavailable icy-notice1:
    SHOUTcast Distributed Network Audio Server/Linux v1.9.8
    icy-notice2:The resource requested is currently unavailable
    

    See shoutcast

  • error while loading shared libraries: libmysqlclient.so.16

    On installing postfix from source, when running the make install command I get an error

    bin/postconf: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
    

    This is because MySQL library path is not in system library locations.

    To fix the error edit /etc/ld.so.conf

    vi /etc/ld.so.conf
    

    Add the following line to the end of the file

    /usr/lib/mysql
    

    Now run ldconfig

    ldconfig
    

    configure: error: “mysql headers missing.”

    Back to Errors

  • configure: error: XML configuration could not be found

    When i install php from source, i get the error

    Running FastCGI Process Manager checks
    checking for php-fpm config file path... $prefix/etc/php-fpm.conf
    checking for php-fpm log file path... $prefix/logs/php-fpm.log
    checking for php-fpm pid file path... $prefix/logs/php-fpm.pid
    checking for XML configuration
    checking for xml2-config... no
    checking for xml-config... no
    configure: error: XML configuration could not be found
    

    The problem is fixed by installing libxml2-devel

    yum install libxml2-devel
    

    See Errors

  • configure: error: Please reinstall the libcurl distribution

    When compiling php from source for nginx web server, i get error

    checking for cURL support... yes
    checking if we should use cURL for url streams... yes
    checking for cURL in default path... not found
    configure: error: Please reinstall the libcurl distribution -
        easy.h should be in /include/curl/
    
    

    On checking, found curl-devel not installed

    [root@vps1 php-5.2.8]# yum list|grep curl
    curl.x86_64                              7.15.5-2.el5           installed
    curl.i386                                7.15.5-2.el5           installed
    curl-devel.x86_64                        7.15.5-2.el5           base
    curl-devel.i386                          7.15.5-2.el5           base
    [root@vps1 php-5.2.8]#
    

    The problem is fixed by installing curl-devel

    yum -y install curl-devel
    

    See Errors

  • configure: error: No curses/termcap library found

    On installing MySQL from source, i get error

    checking for tgetent in -lncurses... no
    checking for tgetent in -lcurses... no
    checking for tgetent in -ltermcap... no
    checking for tgetent in -ltinfo... no
    checking for termcap functions library... configure: error: No curses/termcap library found
    

    SOLUTION

    Lets search for ncurses

    [root@server52 mysql-5.1.23-ndb-6.2.15]# yum list|grep ncurses
    Repository base is listed more than once in the configuration
    Repository addons is listed more than once in the configuration
    Repository extras is listed more than once in the configuration
    ncurses.x86_64                           5.5-24.20060715        installed
    ncurses.i386                             5.5-24.20060715        installed
    ncurses-devel.i386                       5.5-24.20060715        base
    ncurses-devel.x86_64                     5.5-24.20060715        base
    php-ncurses.x86_64                       5.1.6-15.el5           base
    [root@server52 mysql-5.1.23-ndb-6.2.15]#
    

    To fix the problem, install ncurses-devel

    yum -y install ncurses-devel
    

    On Debian/Ubuntu do

    apt-cache search ncurses
    apt-get install libncurses5-dev
    
    [root@server52 mysql-5.1.23-ndb-6.2.15]# yum install ncurses-devel
    Repository base is listed more than once in the configuration
    Repository addons is listed more than once in the configuration
    Repository extras is listed more than once in the configuration
    Setting up Install Process
    Setting up repositories
    Reading repository metadata in from local files
    Parsing package install arguments
    Resolving Dependencies
    --> Populating transaction set with selected packages. Please wait.
    ---> Downloading header for ncurses-devel to pack into transaction set.
    ncurses-devel-5.5-24.2006 100% |=========================|  98 kB    00:00
    ---> Package ncurses-devel.x86_64 0:5.5-24.20060715 set to be updated
    ---> Downloading header for ncurses-devel to pack into transaction set.
    ncurses-devel-5.5-24.2006 100% |=========================|  98 kB    00:00
    ---> Package ncurses-devel.i386 0:5.5-24.20060715 set to be updated
    --> Running transaction check
    
    Dependencies Resolved
    
    =============================================================================
     Package                 Arch       Version          Repository        Size
    =============================================================================
    Installing:
     ncurses-devel           x86_64     5.5-24.20060715  base              1.7 M
     ncurses-devel           i386       5.5-24.20060715  base              1.6 M
    
    Transaction Summary
    =============================================================================
    Install      2 Package(s)
    Update       0 Package(s)
    Remove       0 Package(s)
    
    Total download size: 3.3 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/2): ncurses-devel-5.5- 100% |=========================| 1.7 MB    00:00
    (2/2): ncurses-devel-5.5- 100% |=========================| 1.6 MB    00:00
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing: ncurses-devel                ######################### [1/2]
      Installing: ncurses-devel                ######################### [2/2]
    
    Installed: ncurses-devel.x86_64 0:5.5-24.20060715 ncurses-devel.i386 0:5.5-24.20060715
    Complete!
    [root@server52 mysql-5.1.23-ndb-6.2.15]#
    

    See Errors

  • Lynx

    lynx is a text based browser for Linux and FreeBSD

    http://lynx.isc.org

    Install lynx on CentOS/RHEL/Oracle Linux

    yum install lynx
    

    Install lynx on Debian/Ubuntu

    apt install lynx
    

    Install Lynx from Source

    wget http://lynx.isc.org/release/lynx2.8.5.tar.gz
    tar -zxvf lynx2.8.5.tar.gz
    cd lynx2-8-5
    ./configure
    make
    make install
    

    Install from ports on FreeBSD

    cd /usr/ports/www/lynx
    make
    make install
    make clean
    rehash
    

    On FreeBSD, to see if lynx is installed

    server26# pkg_info|grep lynx
    lynx-2.8.6d18       A non-graphical, text-based World-Wide Web client
    server26#
    

    See Linux Commands