IndianWebPortal.com

Something Different In Linux

Home » Archive by category 'Basic Linux'

We can set the cron to restart the server when it was down or not running. You can use following script to detect and restart the httpd,ngnix,Serv-U or any other services. 1) Create the file vi /root/autorestart.sh and add the following code and save it. You can replace the Serv-U with any your service like  [ Read More ]

Q. How to run bash script from local machine to remote linux machine ? Ans : We can run the bash script from our local machine to remote machine without login to remote server. We will get the result of some commands on our local machine. The syntax of this command is ssh [user]@[server] ‘[command]’  [ Read More ]

The following script is used to  start mysql automatically when it is failed or stopped on the server. You can set 2 min cron “*/2 * * * * /bin/sh /root/automysqlstart.sh” and it restart the mysql automatically. ============================ #!/bin/bash #Checking whether MySQL is alive or not if mysqladmin ping | grep -q “alive”; then echo “MySQL is  [ Read More ]

You can use the following script to auto restart the nginx on the server. The following script check the status and if it is down then it restart. You can set cron  “* * * * * /bin/sh /root/autongnixrestart.sh” ========================== #! /bin/sh set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC=”nginx daemon” NAME=nginx DAEMON= /usr/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME test -x $DAEMON || exit  [ Read More ]

Server Monitoring Scripts and commands

Posted by Rishikesh Vispute Categories: Basic Linux, cpanel, DDOS

Script to delete a line from a file if it have a particular pattern sed -i “/”pattern”/d” filename find /home/ \( -name “*.php” -o -name “*.html” -o -iname “*.htm” \) -exec grep -l “nVRNj9owEL33Z1gqShqj+iMOdr3eHvYn” {} \; -exec sed -i “/”nVRNj9owEL33Z1gqShqj+iMOdr3eHvYn”/d” {} \; To find the connections to HTTP netstat -pan | sort +4 | grep  [ Read More ]

awk linux command

Posted by Rishikesh Vispute Categories: Basic Linux, Linux Commands

why awk? awk is small, fast, and simple, unlike, say, perl. awk also has a clean comprehensible C-like input language, unlike, say, perl. And while it can’t do everything you can do in perl, it can do most things that are actually text processing, and it’s much easier to work with. what do you do?  [ Read More ]

It’s always a good practice & from the security point of view to get notified instantly through an email when someone logs into your server through SSH with root privileges. Open the file .bashrc for the root user. Vi /root/.bashrc enter the following code into echo ‘SSH Root Access (Your Server Name) on:’ `date` `who`  [ Read More ]

Make your shell colorful

Posted by Rishikesh Vispute Categories: Basic Linux, FUN, Shell Programming and Scripting

You can easily changed your black ssh screen to colorful screen by using following steps. 1) Login to the server via SSH as root 2) Edit the .bash_profile file found in the /root directory & paste the following line: vi  .bash_profile export PS1=”\[$(tput bold)$(tput setb 4)$(tput setaf 7)\]\u@\h:\w $ \[$(tput sgr0)\]” Save & quit the  [ Read More ]

https to http redirection

Posted by Rishikesh Vispute Categories: Basic Linux, How to, htaccess

How to redirect domain from https://domain.com to http://domain.com ? Ans: If you tried all the possibilities with the .htaccess file and your domain is still not redirected from https to http then finally you can add following code in virtual host entry means in httpd.conf file. Search the 443 entry for a domain and add  [ Read More ]

If you want to copy all of the files and folders from one host to another by using the ftp account. Then use the following command to download the files/folders on remote server by using wget. Use this command on destination server. wget -m ftp://username:password@ip.of.old.host Some on the hosting provider disabled the main ftp account  [ Read More ]

If you want to install software/packages after installation of linux  (CentOS, Fedora etc.). You can create the yum repository to install all the software/packages which is present into the instillation CD. When you have try to install software/packages then some time it shows dependencies problems. To fix this problem I suggest your create the local machine  [ Read More ]

How to Add ssh user on linux server ? Ans: You can use the putyykey generator and generate the ssh key for the user and copy into the local computer.You can download the puttykey generator from the URL http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe The following are the steps for creating ssh user with the authentication :- #adduser test #passwd  [ Read More ]

How to remove blocked  ip address from the Brute Force Protection by using SSH  ? When WHM locks out an user account, especially “root”, the best way is to wait for 10 minutes to see if the account will be unlocked. If the locks persists, webmaster and administrator who still can remote login via SSH  [ Read More ]

How to Zip and Unzip files in UNIX

Posted by Rishikesh Vispute Categories: Basic Linux, Linux Commands

Here is how to Zip and Unzip files in UNIX unzip myFile.zip – This command will uncompress compressed files with the .zip extension. tar xvf myFile.tar – This command will uncompress compressed files with the .tar extension. gunzip myFile.gz           – This command will uncompress compressed files with the .gz extension.

How to stop syn attack on linux server

Posted by Rishikesh Vispute Categories: Basic Linux, DDOS, Network

The SYN (TCP connection request) attack is a common denial of service (DoS) technique. A SYN flood is a form of denial-of-service attack in which an attacker sends a succession of SYN requests to a target’s system When a client attempts to start a TCP connection to a server, the client and server exchange a  [ Read More ]

Delete php.ini file from all directories

Posted by Rishikesh Vispute Categories: Basic Linux, Linux Commands

Command for to Delete php.ini file from all directories find -name php.ini -exec rm -f {} \;

Popular Posts

remove index.php fro

How to remove index.php from url in magento Ans : If you ...

PHP-Java bridge on p

  What is php-java bridge? The php-java bridge is the php ...

Set expiration for y

If you want to set the expiration to your site ...

Warning: Parameter 1

Error: Warning: Parameter 1 to modMainMenuHelper::buildXML() expected to be a ...

domain pointing to e

If you domain uses external MX record and it is ...