Category: Linux

  • Enable rc.local

    To enable /etc/rc.local file run on system startup on servers runing systemd, you can run

    systemctl enable rc-local
    

    Now you need to create file /etc/rc.local with 755 permission.

    touch /etc/rc.local
    chmod 755 /etc/rc.local
    

    See Autostart

  • proxychains

    proxychains allow you to route traffic using proxy servers. This is useful for routing traffic throihg applications that do not support proxy by default. For example, i use ssh through proxy chains.

    To install proxychains on Ubuntu, run

    apt install -y proxychains
    

    Now you need to edit /etc/proxychains.conf and add your proxy servers.

    sudo vi /etc/proxychains.conf 
    

    On my computer, i use SSH tunnel to a sevrer on port 7878, so i added following to end of my proxychains.conf

    socks5  127.0.0.1  7878
    

    To text proxy proxychains, run

    boby@sok-01:~$ curl checkip.amazonaws.com
    59.92.71.53
    boby@sok-01:~$ proxychains curl checkip.amazonaws.com
    ProxyChains-3.1 (http://proxychains.sf.net)
    |DNS-request| checkip.amazonaws.com 
    |S-chain|-<>-127.0.0.1:7878-<><>-4.2.2.2:53-<><>-OK
    |DNS-response| checkip.amazonaws.com is 34.193.115.2
    |S-chain|-<>-127.0.0.1:7878-<><>-34.193.115.2:80-<><>-OK
    51.38.246.115
    boby@sok-01:~$ 
    

    As you can see when using proxychains, you get a difernt IP as traffic get routed through proxy server specified in proxychains.conf

    Proxychains show some connection info, you can hide this by editing proxychains.conf and uncommenting the line

    # Quiet mode (no output from library)
    #quiet_mode
    

    With quite mode enabled, you will see

    boby@sok-01:~$ proxychains curl checkip.amazonaws.com
    ProxyChains-3.1 (http://proxychains.sf.net)
    51.38.246.115
    boby@sok-01:~$ 
    

    See Proxy

  • Server Load

    Here are some useful commands to check server load.

    iostat shows disk IO usage. %iowait shows how much time the process waits for disk operation. This should be 0. If you are on VPS, check for %steal to see if the host server is overloaded.

    iostat 1 10
    

    Checks for processes in ā€˜Dā€™ state

    for x in `seq 1 1 30`; do ps -eo state,pid,cmd | grep "^D"; echo "-"; sleep 2; done
    

    Top processes using CPU resources

    top -bn 1 | head -20
    

    Check Running Process

    ps aux
    top
    atop
    pstree
    

    Check For Bad Scripts

    WPRobot plugin for wordpress take lot of cpu usage, find sites using WPRobot

    find /home -name 'wprobot.php'
    
  • Requesting a zone trasnfer with dig

    To request a zone transfer using dig, use

    dig @NAME_SERVER_HERE  -t AXFR  DOMAIN_NAME_HERE
    

    Example

    [root@vps3 poweradmin]# dig @server10.hosthat.com  -t AXFR  bizhat.com
    
    ; <<>> DiG 9.5.1-P2-RedHat-9.5.1-2.P2.fc10 <<>> @server10.hosthat.com -t AXFR bizhat.com
    ; (1 server found)
    ;; global options:  printcmd
    bizhat.com.             86400   IN      SOA     dns10.hosthat.com. hostonnet.gmail.com. 2008091126 7100 7200 2419100 86400
    bizhat.com.             14400   IN      MX      0 server52.hosthat.com.
    bizhat.com.             86400   IN      NS      dns10.hosthat.com.
    bizhat.com.             86400   IN      NS      server70.hosthat.com.
    bizhat.com.             14400   IN      A       67.228.96.44
    *.bizhat.com.           14400   IN      A       66.90.101.78
    aaj.bizhat.com.         14400   IN      A       67.228.37.136
    adserver.bizhat.com.    14400   IN      A       174.37.154.236
    advt.bizhat.com.        14400   IN      A       67.228.95.96
    alappuzha.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    angamaly.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    arthunkal.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    astrology.bizhat.com.   14400   IN      A       67.228.37.136
    austin.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    autos.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    bangalore.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    banner.bizhat.com.      14400   IN      A       67.228.37.136
    bb.bizhat.com.          14400   IN      A       76.76.18.19
    beauty.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    bizhat-radio.bizhat.com. 14400  IN      A       72.21.41.242
    blog.bizhat.com.        14400   IN      A       76.76.18.23
    *.blog.bizhat.com.      14400   IN      A       76.76.18.23
    blogs.bizhat.com.       14400   IN      A       208.53.161.106
    books.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    bsc.bizhat.com.         14400   IN      A       67.228.37.136
    calendar.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    chat.bizhat.com.        14400   IN      A       67.228.37.136
    chellanam.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    cherthala.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    cherthalainfo.bizhat.com. 14400 IN      CNAME   cms.bizhat.com.
    classifieds.bizhat.com. 14400   IN      A       67.228.37.136
    cms.bizhat.com.         14400   IN      A       76.76.18.22
    computer.bizhat.com.    14400   IN      A       67.228.37.136
    counter.bizhat.com.     14400   IN      A       76.76.18.19
    dating.bizhat.com.      14400   IN      A       76.76.18.23
    dileep.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    dir.bizhat.com.         14400   IN      A       72.36.166.222
    directory.bizhat.com.   14400   IN      A       67.228.96.44
    divyaunni.bizhat.com.   14400   IN      A       67.228.96.44
    domainname.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    domains.bizhat.com.     14400   IN      A       67.228.37.136
    downloads.bizhat.com.   14400   IN      A       67.228.95.96
    ecards.bizhat.com.      14400   IN      A       67.228.37.136
    education.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    emedia.bizhat.com.      14400   IN      A       67.228.37.136
    ernakulam.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    ezhupunna.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    filmreviews.bizhat.com. 14400   IN      A       76.76.18.23
    finance.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    findhost.bizhat.com.    14400   IN      A       67.228.37.136
    forums.bizhat.com.      14400   IN      A       69.59.28.85
    free.bizhat.com.        14400   IN      A       208.53.161.106
    freeforums.bizhat.com.  14400   IN      A       208.53.161.107
    freeinfo.bizhat.com.    14400   IN      A       67.228.37.136
    freelance.bizhat.com.   14400   IN      A       67.228.37.136
    friends.bizhat.com.     14400   IN      A       65.98.61.140
    ftp.bizhat.com.         14400   IN      CNAME   bizhat.com.
    gallery.bizhat.com.     14400   IN      A       69.59.28.85
    games.bizhat.com.       14400   IN      A       67.228.37.136
    gifts.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    git.bizhat.com.         14400   IN      A       67.228.104.123
    gptcktm.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    guestbook.bizhat.com.   14400   IN      A       67.228.37.136
    gujarat.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    hamradio.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    health.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    home.bizhat.com.        14400   IN      A       67.228.37.136
    homebiz.bizhat.com.     14400   IN      A       67.228.37.136
    hosted.bizhat.com.      14400   IN      A       67.228.37.136
    hosting.bizhat.com.     14400   IN      A       67.228.37.136
    hotels.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    htmltutorial.bizhat.com. 14400  IN      CNAME   cms.bizhat.com.
    idukki.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    image.bizhat.com.       14400   IN      A       74.86.201.216
    imagehost.bizhat.com.   14400   IN      A       67.228.104.120
    images.bizhat.com.      14400   IN      A       74.86.201.216
    img1.bizhat.com.        14400   IN      A       69.59.28.86
    img2.bizhat.com.        14400   IN      A       76.76.18.24
    img3.bizhat.com.        14400   IN      A       67.228.104.120
    img4.bizhat.com.        14400   IN      A       208.53.161.108
    img5.bizhat.com.        14400   IN      A       76.76.18.24
    india.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    interactivecd.bizhat.com. 14400 IN      A       67.228.37.136
    iptools.bizhat.com.     14400   IN      A       67.228.96.44
    ishtam.bizhat.com.      14400   IN      A       67.228.37.136
    jagathi.bizhat.com.     14400   IN      A       67.228.96.44
    jayaram.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    jobs.bizhat.com.        14400   IN      A       76.76.18.23
    jokes.bizhat.com.       14400   IN      A       67.228.37.136
    kannur.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    karnataka.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    kasaragod.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    kashmir.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    kerala.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    kidsempire.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    kochi.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    koilparampil.bizhat.com. 14400  IN      CNAME   cms.bizhat.com.
    kollam.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    kottayam.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    kovalam.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    kozhikode.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    kumarakom.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    kunchackoboban.bizhat.com. 14400 IN     A       67.228.96.44
    labs.bizhat.com.        14400   IN      A       69.93.202.216
    lifestyle.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    linuxcd.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    localhost.bizhat.com.   14400   IN      A       127.0.0.1
    lonavala.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    lotus.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    mail.bizhat.com.        14400   IN      A       76.76.18.23
    www.mail.bizhat.com.    14400   IN      A       76.76.18.23
    malappuram.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    mammooty.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    mano.bizhat.com.        14400   IN      A       67.228.95.96
    www.mano.bizhat.com.    14400   IN      A       67.228.95.96
    mariasadanam.bizhat.com. 14400  IN      CNAME   cms.bizhat.com.
    media.bizhat.com.       14400   IN      A       76.76.18.22
    mohanlal.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    movies.bizhat.com.      14400   IN      A       74.86.201.216
    munnar.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    music.bizhat.com.       14400   IN      A       67.228.37.136
    news.bizhat.com.        14400   IN      A       67.228.96.44
    newsletter.bizhat.com.  14400   IN      A       67.228.95.96
    newstar.bizhat.com.     14400   IN      A       67.228.37.136
    novel.bizhat.com.       14400   IN      A       67.228.37.136
    palakkad.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    pallipuram.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    pallithode.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    pathanamthitta.bizhat.com. 14400 IN     CNAME   cms.bizhat.com.
    pets.bizhat.com.        14400   IN      CNAME   cms.bizhat.com.
    phpbb.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    phptutorial.bizhat.com. 14400   IN      CNAME   cms.bizhat.com.
    postfix.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    print.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    qmail.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    radio.bizhat.com.       14400   IN      A       67.228.96.44
    ranakpur.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    realestate.bizhat.com.  14400   IN      A       67.228.37.136
    recipes.bizhat.com.     14400   IN      A       67.228.37.136
    s1.bizhat.com.          14400   IN      A       76.76.18.23
    *.s1.bizhat.com.        14400   IN      A       76.76.18.23
    s2.bizhat.com.          14400   IN      A       76.76.18.21
    *.s2.bizhat.com.        14400   IN      A       76.76.18.21
    s3.bizhat.com.          14400   IN      A       76.76.18.21
    *.s3.bizhat.com.        14400   IN      A       76.76.18.21
    s4.bizhat.com.          14400   IN      A       76.76.18.21
    *.s4.bizhat.com.        14400   IN      A       76.76.18.21
    salu.bizhat.com.        14400   IN      CNAME   cms.bizhat.com.
    sanjeevani.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    screensaver.bizhat.com. 14400   IN      A       67.228.37.136
    scripts.bizhat.com.     14400   IN      A       67.228.37.136
    search.bizhat.com.      14400   IN      A       67.228.37.136
    sites.bizhat.com.       14400   IN      CNAME   cms.bizhat.com.
    smartboss.bizhat.com.   14400   IN      A       174.37.154.236
    sms.bizhat.com.         14400   IN      A       76.76.18.23
    star.bizhat.com.        14400   IN      CNAME   cms.bizhat.com.
    stefin.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    stmarys.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    www.stmarys.bizhat.com. 14400   IN      CNAME   cms.bizhat.com.
    submit.bizhat.com.      14400   IN      A       67.228.37.136
    sureshgopi.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    test.bizhat.com.        14400   IN      A       67.228.37.136
    thanki.bizhat.com.      14400   IN      CNAME   cms.bizhat.com.
    thiruvananthapuram.bizhat.com. 14400 IN CNAME   cms.bizhat.com.
    thrissur.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    top100.bizhat.com.      14400   IN      A       76.76.18.23
    tourism.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    tutorials.bizhat.com.   14400   IN      CNAME   cms.bizhat.com.
    uploads.bizhat.com.     14400   IN      A       67.228.226.99
    uploads.bizhat.com.     14400   IN      A       76.76.18.19
    ftp.uploads.bizhat.com. 14400   IN      A       208.53.170.247
    s1.uploads.bizhat.com.  14400   IN      A       127.0.0.1
    s2.uploads.bizhat.com.  14400   IN      A       208.53.168.39
    s3.uploads.bizhat.com.  14400   IN      A       208.53.168.13
    s4.uploads.bizhat.com.  14400   IN      A       208.53.158.66
    s5.uploads.bizhat.com.  14400   IN      A       67.159.61.214
    s6.uploads.bizhat.com.  14400   IN      A       67.159.60.15
    s7.uploads.bizhat.com.  14400   IN      A       66.90.104.210
    s8.uploads.bizhat.com.  14400   IN      A       208.53.136.114
    s9.uploads.bizhat.com.  14400   IN      A       66.90.104.184
    www.uploads.bizhat.com. 14400   IN      A       67.228.226.99
    uploads-nu-s54.bizhat.com. 14400 IN     A       76.76.18.23
    varkala.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    video.bizhat.com.       14400   IN      A       67.228.116.84
    s1.video.bizhat.com.    14400   IN      A       69.59.28.86
    s2.video.bizhat.com.    14400   IN      CNAME   1wp-f2a00a0000000000.id.velocix.com.
    static1.video.bizhat.com. 14400 IN      A       76.76.18.24
    visitation.bizhat.com.  14400   IN      CNAME   cms.bizhat.com.
    wayanad.bizhat.com.     14400   IN      CNAME   cms.bizhat.com.
    webftp.bizhat.com.      14400   IN      A       208.53.161.106
    webmaster.bizhat.com.   14400   IN      A       67.228.37.136
    world.bizhat.com.       14400   IN      A       67.228.37.136
    worldseven.bizhat.com.  14400   IN      A       127.0.0.2
    www.bizhat.com.         14400   IN      CNAME   bizhat.com.
    yearofdevil.bizhat.com. 14400   IN      A       67.228.37.136
    yellowpages.bizhat.com. 14400   IN      A       67.228.95.96
    yourname.bizhat.com.    14400   IN      CNAME   cms.bizhat.com.
    youtubescript.bizhat.com. 14400 IN      A       67.228.192.156
    bizhat.com.             86400   IN      SOA     dns10.hosthat.com. hostonnet.gmail.com. 2008091126 7100 7200 2419100 86400
    ;; Query time: 113 msec
    ;; SERVER: 67.228.226.101#53(67.228.226.101)
    ;; WHEN: Mon Jul  6 04:22:03 2009
    ;; XFR size: 199 records (messages 1, bytes 4605)
    
    [root@vps3 poweradmin]#
    

    See dig

  • Steam store games on different Disk

    I have a 250 GB SSD as boot drive. My steam games installed on a 2nd 2 TB hard disk. After reinstalling Ubuntu, i installed steam with.

    apt install steam
    

    Steam does not show the games installed on the 2 TB HDD.

    To get the games work, i renamed steamapps folder, them created a symlink to directory on the 2 TB HDD where games are installed.

    Stop steam, then do the following. /mnt/data/SteamLibrary/steamapps is the directory where my games are installed. Change it to whatever directory where your games are installed.

    cd ~/.steam/debian-installation/
    mv steamapps steamapps-old
    ln -s /mnt/data/SteamLibrary/steamapps
    

    Now start Steam, you will see the games.

  • GNOME Shell Extension

    GNOME Shell Extensions allow you to add/modify features in Gnome Desktop. Gnome Desktop is used by Ubuntu.

    Shell Extensions are stored in folder

    /home/USER/.local/share/gnome-shell/extensions
    

    On Ubuntu 20.04, i installed NoAnnoyance extension. This prevent Annoying Windows Ready notification.

    https://extensions.gnome.org/extension/1236/noannoyance/

    To install an extension, go to the web page of the extension, you will be asked to install a browser extension. Once browser etxtension installed, you need to install

    sudo apt install chrome-gnome-shell
    

    This is same for both Google Chrome and Firefox. Now you can go to any extension page, select “ON/OFF” button on the page to install an extension.

    Extensions i use on Ubuntu 20.04

    Ubuntu don’t have a quick way to switch between sound devices. For example switching between headphone and speaker. I used Sound Input & Output Device Chooser for very long. On 2021-03-30, it stopped working. I started using a differnt extension Audio output selector, this have less features, but do the work properly.

    List all Gnome Extensions

    To list all gnome extensions, run “gnome-extensions list”.

    boby@sok-01:~$ gnome-extensions list
    desktop-icons@csoriano
    [email protected]
    [email protected]
    [email protected]
    [email protected]
    boby@sok-01:~$ 
    

    To enable/disable an extension, use

    gnome-extensions enable EXTENSION_NAME
    gnome-extensions disable EXTENSION_NAME
    

    Example

    gnome-extensions disable [email protected]
    
  • Install TeamSpeak Client on Ubuntu

    Install TeamSpeak Client on Ubuntu

    To install TeamSpeak client on Ubuntu, download latest version from

    https://www.teamspeak.com/en/downloads/

    Download page list both 32 and 64 bit versions. Most computers these days use 64 bit OS. So download 64 bit version unless you are using older computer with 32 bit OS.

    TeamSpeak Client Ubuntu

    On Ubuntu, you can find if you are using 32 or 64 bit version with command arch

    boby@sok-01:~$ arch
    x86_64
    boby@sok-01:~$ 
    

    Download latest version of TeamSpeak, as for this writing, latest verison is

    wget https://files.teamspeak-services.com/releases/client/3.5.5/TeamSpeak3-Client-linux_amd64-3.5.5.run
    

    Make it executable

    chmod 755 TeamSpeak3-Client-linux_amd64-3.5.5.run
    

    To extract it, run

    ./TeamSpeak3-Client-linux_amd64-3.5.5.run
    

    This will cretae a folder with TeamSpeak files. Move it to /opt directory or any other folder you prefer.

    mv TeamSpeak3-Client-linux_amd64 /opt/
    

    Now you can start TeamSpeak from command line with command

    /opt/TeamSpeak3-Client-linux_amd64/ts3client_runscript.sh
    

    To create a shortcut file, create a desktop file

    vi ~/.local/share/applications/teamspeak.desktop
    

    Add following content

    [Desktop Entry]
    Name=TeamSpeak 3
    Comment=TeamSpeak 3 VoIP Communicator
    Exec=/opt/TeamSpeak3-Client-linux_amd64/ts3client_runscript.sh
    Terminal=false
    Type=Application
    Categories=Network;Application;
    Icon=/opt/TeamSpeak3-Client-linux_amd64/styles/default/logo-128x128.png
    

    Now you will be able to find TeamSpeak 3 in Ubuntu Start menu/Dash.

    See Ubuntu

  • configure: error: “curses not found”

    When installing a software from source, i get errro

    configure: error: "curses not found"
    

    To fix this, install libncurses-dev

    apt install libncurses-dev
    

    See Errors

  • configure: error: “libevent not found”

    When installing a software from source i get error

    configure: error: "libevent not found"
    

    To fix, install libevent-dev

    apt install libevent-dev
    

    See Errors

  • Bash check if a directory exists

    To check if a directory exists in bash, use

    if [[ -d "/path/to/directory/" ]]
    then
        echo "Directory found."
    fi
    

    To check for absense of a directory, use !

    if [[ ! -d "/path/to/directory/" ]]
    then
        echo "Directory not found."
    fi
    

    See bash

  • ErpNext backup a site

    To backup a site in ErpNext, you need to backup files and database.

    To backup files, run

    frappe@sok:~/frappe-bench$ bench --site erp.serverok.in backup --with-files
    Backed up files /home/frappe/frappe-bench/sites/erp.serverok.in/private/backups/20201112_140222-erp_grandeh_com-files.tar
    Backed up files /home/frappe/frappe-bench/sites/erp.serverok.in/private/backups/20201112_140222-erp_grandeh_com-private-files.tar
    frappe@sok:~/frappe-bench$ 
    

    To Backup database, run

    frappe@sok:~/frappe-bench$ bench --site erp.serverok.in backup
    frappe@sok:~/frappe-bench$ 
    

    To backup all sites, use

    cd /home/frappe/frappe-bench && bench --verbose --site all backup
    

    Backups are stored in folder

    /home/frappe/frappe-bench/sites/erp.serverok.in/private/backups/
    

    To restore a backup, you need to use the 3 files (private files, public files and database backup). To restore backup, check ErpNext restore backup.

    See ErpNext