Shell Script To Check File Exists Under A Path

This Shell script helps to check if the specified file exits under a given path. Script prompt you to provide file name and directory path. Shell Script #!/bin/bash #We tell user that he need to enter filename echo -n "Please enter file to check: " #We write filename to variable file read file #We tell […]

May 26, 2013 | By
| Reply More

Shell Script To Run Commands In Users Home Directory

Shell script that run linux commands in all users home directories and outputs its results. Scripts accepts user name and command as the argument. Shell Script #Next line tell with shell to use #!/bin/bash #we store in variable path to file UserListFile=/tmp/user.list #We create function with name Usage Usage () { #printing help echo "$0 […]

May 22, 2013 | By
| Reply More

Linux Shell Script To Delete Duplicate Files

Shell Script is looking for duplicated names in files withing sub-directories, and after check md5sum. If md5sum of the files same then we conclude its duplicated. This helps system administrator to delete unnecessary copy to reduce used space. Script also ask user to enter directory where to search, and check if input is empty. Linux […]

May 19, 2013 | By
| 2 Replies More

Shell Script To Find Directories Which Consume Highest Space

Shell script to show X number of directories that consume space in a path. This script useful if user need quickly to clean up space, so first user need to check what directory take most of space and the delete according to your wish. Commands used are du with different keys , then sort and […]

May 16, 2013 | By
| Reply More

Linux Shell Script To Collect Linux System Information

Shell script that take info about linux system like logged users, uptime, load average, free memory, disk usage. Script helps to see all info about system in a second. Administrator can modify the script bit ,if it requires to find system information from multiple server. Script run commands w, uname, uptime, free and df. From […]

May 12, 2013 | By
| Reply More

Shell Script : Backup MySql Databases In Compressed Format

This shell script will create dump of all databases from mysql server. Allow system administrator to have backups of all databases. The output would be in a tar.gz zipped format. Script is using mysqldump and tar command for this purpose. Shell Script #!/bin/bash #Check if user input hostname, if not – exit from script if […]

April 28, 2013 | By
| Reply More

Linux Shell Script: Find Interface IP Address From Multiple Linux Servers

This shell script can used to find ethernet interface details and ip address /subnet mask assigned from multiple servers. Script will also display interface name even if no ip address is set. Make sure you have authorized keys set so each server can be logined using ssh without a password. Linux Shell Script #!/bin/bash #we […]

April 20, 2013 | By
| Reply More

Shell Script : Interactive Way To Create Mysql User And Grant Access

Shell script help user to create user in mysql database, when user don't know about mysql, but need quickly add new user. Script should run only from user that have passwordless access to mysql. Shell Script #!/bin/bash #Ask user to enter database name and save input to dbname variable read -p "Please Enter Database Name:" […]

April 7, 2013 | By
| 2 Replies More

Shell Script : Find Files Older X Days And Ask User To Delete

Script that find files older X days and ask user to delete them. Useful for administrator, if needed quickly find old files and delete required files. Script will interactively ask user before deleting the older files. Shell Script #!/bin/bash #we check for parameters #Directory is requirede parameter, to avoid deleting from any other folders if […]

April 5, 2013 | By
| Reply More

Linux Shell Script To Monitor Ftp Server Connection

Main goal of this script is to monitor ftp server. This script is example of how to use ftp command in bash shell. System administrator can use this script to check if ftp server alive and upload there any data/backups. Everytime script create new file, every time with with different md5 sum, after script upload […]

March 26, 2013 | By
| Reply More

Interactive Linux Shell Script To Create New Linux User

Script helps to remember all main points during creating user and quickly create new user. If admin need to create 100 users at once this script could be helpful. Script use command useradd with keys and groupadd. Shell Script #!/bin/bash while [ x$username = "x" ]; do read -p "Please enter the username you wish […]

March 24, 2013 | By
| 2 Replies More

Shell Script : Find All Zip / Rar Files Then Unzip / Unrar

Script that find all rar files in all sub-directories and unrar them to same destination. Shell script will shows how to find all rar files and assign to a variable. Commands are run on each file on the list. Shell Script #!/bin/bash list=`find /home/linoxide/ -type f -name "*.rar"` for line in $list; do DEST=${line%/*} unrar […]

March 20, 2013 | By
| Reply More

Shell Script : Service Status Check And start If It's Not Running

Shell Script that check if service is running and if its not then will try to start it. Its good for system admin to make sure the crucial services are running all the time. Shell Script #!/bin/bash if [ "$#" = 0 ] then echo "Usage $0 " exit 1 fi service=$1 is_running=`ps aux | […]

March 10, 2013 | By
| Reply More

Linux Shell Script To Check Disk Usage Is Out Of Space

Script that check used space on all mounted devices and warn if the used space is more than the threshold. In this scenario we were using 25% of disk, that's why threshold is so small. Linux Shell Script #!/bin/bash threshold="20" i=2 result=`df -kh |grep -v "Filesystem" | awk '{ print $5 }' | sed 's/%//g'` […]

March 5, 2013 | By
| 1 Reply More