Tag archive for ‘Script’

FreeBSD How to restart inetd service / daemon

inetd is referred to as the Internet Super-Server because it manages connections for several services. When a connection is received by inetd, it determines which program the connection is destined for, spawns the particular process and delegates the socket to it. First login as a root user. FreeBSD version 5.0/6.0 or later Newer version of [...]

Script to find how many mails sent from an account

grep xxx@xxx.com /var/log/exim_mainlog | grep “<=” | awk {’print $3′} | wc -l

Shell Script List All Top IP Address Accessing Apache / Lighttpd Web Server

#!/bin/bash # Shell Script To List All Top Hitting IP Address to your webserver. # This may be useful to catch spammers and scrappers. # ———————————————————————- # This script is licensed under GNU GPL version 2.0 or above # ———————————————————————- # where to store final report? DEST=/var/www/reports/ips # domain name DOM=$1 # log file location [...]

Script for restarting apache at load 10

#!/bin/bash loadavg=$(uptime | awk -F “.” ‘{ print $1 }’ | awk -F “:” ‘{ print $5 }’) if [ "$loadavg" -ge "10" ]; then pkill -9 httpd sleep 3 /scripts/restartsrv_httpd fi

Shell Script to read source file and copy it to target file

#!/bin/bash # Shell to read source file and copy it to target file. If the file # is copied successfully then give message ‘File copied successfully’ # else give message ‘problem copying file’ # ————————————————————————- # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # [...]

Shell script to find all programs and scripts with setgid bit set on

setuid and setgid (short for set user ID upon execution and set group ID upon execution, respectively) are Unix access rights flags that allow users to run an executable with the permissions of the executable’s owner or group. They are often used to allow users on a computer system to run programs with temporarily elevated [...]

Script to email failed Ftp login attempts

Shell Script to search Failed Ftp Login Attempts This Shell script will search the server logs on daily basis and will email you the Failed Ftp Login Attempts of the day. The ftp logs are saved in the /var/log/messages file as by default there is no separate log file for Ftp in Linux. Create a [...]

Shell script to Finding ALL Superuser ( root ) Accounts under UNIX / Linux OSes

In Unix-style computer operating systems, root is the conventional name of the user who has all rights or permissions in all modes (single- or multi-user). The root user can do many things an ordinary user cannot, such as changing the ownership of files and binding to ports numbered below 1024. It is never good practice [...]

Script used to correct permission of files after suphp

Script used to correct permission of files after suphp #!/bin/bash # For some stupid reason, cPanel screws up the directory permissions. chmod 755 /opt/suphp find /opt/suphp -type d -exec chmod 755 {} \; # Ensure that the permissions are sane and won’t cause a 500 error. for user in `/bin/ls /var/cpanel/users`; do chown -R ${user}:${user} [...]

Script to create multiple accounts

Script to create multiple accounts for cpanel #! /bin/bash #make a file (test1) which contains domain names, username and password. #then run the script: for i in `cat test1` do domain=`echo $i | cut -f1 -d:` un=`echo $i | cut -f2 -d:` pw=`echo $i | cut -f3 -d:` /scripts/wwwacct $domain $un $pw 0 done Incoming [...]