Category: Linux

  • chmod recursive with lftp

    lftp is a command line FTP program with several advanced options.

    To chmod all files and folders inside a sub folder, you can use -R option.

    chmod -R 777 modules
    

    This will chmod all files and subfolders inside the folder “modules” to 777.

    See lftp

  • lftp enable debug mode

    To enable debug mode, add -d to command line like

    lftp -d -u bizhat,UdddaaaaaartN 174.36.192.112
    

    See lftp

  • Download all files from FTP server using lftp

    lftp is a command line FTP client, that can be used to download all files from a remote FTP server to local folder.

    This is useful when you want to move migrate site from one server to another.

    To download all files from FTP server, create an empty folder and change to it.

    mkdir ~/sok-move
    cd ~/sok-move
    

    Run lftp command to connect to remove FTP server.

    lftp -u FTP_SERVER_USER,'FTP_SERVER_PW' FTP_SERVER_IP
    

    This will connect you to FTP server. Run following 2 commands as needed. First command will disable SSL, this is required if remote FTP server have no SSL installed. Second command will enable active FTP mode, will be useful if passive FTP don’t work for you.

    set ftp:ssl-allow false
    set ftp:passive-mode off
    set ssl:verify-certificate no
    

    Change the folder that you need to download and run

    mirror
    

    This will download everything from remote FTP server to your local folder.

    You can use options

    mirror -c --parallel=10
    

    Here -c is for continue, will help with resume if you get disconnected or want to mirror again.

    –parallel=10 will tell lftp to download 8 files in parallel instead of files one by one.

    See lftp

  • Install vnstat on CentOS 7

    To install vnstat on CentOS 7, run

    yum install vnstat -y
    

    Now create database for your network interface card

    vnstat --create -i NETWORK_INTERFACE_NAME
    

    Restart vnstat deamon

    systemctl restart vnstat
    

    See vnstat

  • Install RabbitMQ on Ubuntu/Debian

    To install rabbitmq on Ubuntu/Debian, run

    echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
    wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
    apt update
    apt install rabbitmq-server
    

    To start RabbitMQ server, run

    service rabbitmq-server start
    
  • Install ansible on Ubuntu

    To install ansible on Ubuntu, run

    apt-get -y update
    apt-get -y install software-properties-common
    apt-add-repository ppa:ansible/ansible -y
    apt-get -y update
    apt-get -y install ansible
    
  • Install Transmission on CentOS

    Install Transmission on CentOS

    transmission is a torrent client. This come with a web GUI, that make it easy to installed on a remote server with no X-Windows. To install transmission on CentOS server, run

    yum install -y transmission-daemon transmission-cli
    

    Allow Web Access

    To access transmission web GUI, you need to white list your IP address. To do this, first stop tranmission

    service transmission-daemon stop
    

    Edit file

    vi /var/lib/transmission/.config/transmission/settings.json
    

    Find

        "rpc-whitelist": "127.0.0.1",
    

    Replace with

        "rpc-whitelist": "127.0.0.1,YOUR_IP_ADDR_HERE",
    

    YOUR_IP_ADDR_HERE – replace with your actual IP address.

    Start transmission

    service transmission-daemon start
    

    You will be able to access web GUI at

    http://YOUR_SERVER_IP:9091
    

    Downloaded files are stored in folder

    /var/lib/transmission/Downloads
    
  • How to protect .git folder using htaccess

    GIT is popular version control software, this work like a time machine. You can easily get older versions of code. Each changes are stored as commit, so it work like a time machine for source code.

    If you put your .git folder in a publically accessable folder, others will be able to access your source code. It is better put this folder outside of DocumentRoot folder.

    If your .git folder is on public folder, then use following .htaccess code to block access to it.

    RedirectMatch 404 /\.git
    

    Method 2

    Create an .htaccess file inside .git folder with content

    deny from all