Tuesday, December 23, 2014

Saturday, July 12, 2014

script to take input from user and to do backup as they wish

Here is the script to take input from user and to do backup as they wish.



#!/bin/bash
dialog --inputbox " Please Enter the location where back will be stored" 9 50 2>/tmp/i1
a0=`cat /tmp/i1`
test ! -d $a0 && dialog --msgbox " $a0 dont exit .. we will make for u " 9 50 && mkdir $a0   && dialog --msgbox  "ok $a0 made " 9 50 || dialog --msgbox " Destination $a0  exist/or its cant be made  ... we will go forward " 9 50
dialog --inputbox " Please Enter the location to back-up" 9 50 2>/tmp/i2
a1=`cat /tmp/i2` && dialog --msgbox "Searching for  backed-up location $b "
test ! -d $b1  && dialog --msgbox "$a1 does not exist ...back-up will not be done " 9 50 || dialog --msgbox " OK $a1 found ..  we will go for back up " 9 50
tar cvzf $a0/backup.tar.gz $a1 && dialog --msgbox " congrats we have done back-up for u " 9 50 || dialog --msgbox "Sorry error occured" 9 50
rm -f /tmp/i1
rm -r /tmp/i2

just copy the above file to your Desktop to a file named "a"

and do the following steps

1. open your terminal and go for Desktop and type "sudo chmod +x a


2. then type ./a

will be seen as follow

  




Sunday, June 15, 2014

script to encrypt any file with password

Some times we need to encrypt  any file before sending to others , through mail or by any mean.


Script to encrypt any file




#!/bin/bash

echo "Enter the file location and file name to encrypt "

read a

 gpg -c $a

echo "OK its done , now the original file will be deleted "



rm -rf $a

and when the receiver will receive the file he will decrypt the same file the following way


gpg -d 2.gpg > 3




before encrypting the file name 2 



after encrypting the file name 2



after recovering the file and named it as 3



Friday, May 23, 2014

Script to convert any file format to mp3 in Linux

Here is my script that will convert any file format to mp3

like

mp4 to mp3

avi to mp3

3gp to mp3

webm to mp3

any thing to mp3

open your terminal type :

sudo apt-get install ffmpeg libavcodec-extra-53

now type : gedit convert 

and past the following script   :

#!/bin/bash
# This script will convert files to mp3 format
#Writer Anuj Borah (anujborah3@gmail.com)
echo "please enter the directory of the targeted file "
read d
cd $d
echo "now enter the name of file you want to convert to mp3 "
read d1
ffmpeg -i $d1 anuj.mp3
echo "OK we are done!  your file is converted to $d/anuj.mp3 "
exit 0




type : sudo chmod +x convert


then type:   ./convert



see simple output :


Thursday, May 22, 2014

How to find out linux system IP Add with a single script

This script will find your system's IP add with the interface you are using currently .

just copy and past the following to  Desktop  .


 #!/bin/sh
ifconfig>/home/u-man/Desktop/1
grep "inet addr:" /home/u-man/Desktop/1>/home/u-man/Desktop/2
sed -n '2p' /home/u-man/Desktop/2
exit 0






save it as shell

now open terminal type :

cd /home/user/Desktop

sudo chmod +x shell

 now ./shell


see my output





Wednesday, May 21, 2014

How to take backup of linux system

We have a important directory say /home/user/Picture  in my case user=u-man

, everyday new contents are added there , these data s are important we need to take a backup it every day , how ??


our target directory =      /home/user/Picture

we will make a backup of above directory

open terminal type :

cd Desktop

tar cvzf anuj.tar.gz /home/u-man/Pictures

it will make a anuj.tar.gz file on desktop

now copy and past following script

#!/bin/bash

gunzip /home/u-man/Desktop/anuj.tar.gz
tar uvf /home/u-man/Desktop/anuj.tar /home/user/Picture
gzip /home/u-man/Desktop/anuj.tar.gz
exit 0


save it ass shell

now type: sudo chmod +x shell

now every day before shutting down your PC you need to do only  one thing that is  :  ./shell

see the screen shoot 







script-to-take-backup-of-linux-system

Monday, May 19, 2014

How to add two or more than two virtual host in apache web server

We have already installed apache web server. By default it will have only one host machine will have only one host.

By default the directory for apache web server is /var/www directry you can change it by editing "/etc/apache2/sites-available/default" file    



We will see how to make name based and ip based virtual hosting in apache web server.


first you need to install apache web server , open terminal type

"sudo apt-get install apache2"

after installation, open firefox web browser type "127.0.01" or "localhost"

you will see your index page of apache web server.

Now we need another two host called "uman.com" and "anuj.borah.com"

Lets see how i will do it .


The root of document for uman.com will be /home/user/Pictures/uman.com

and root of document for anuj.borah.com will be /home/user/Pictures/anuj.borah.com

here in my case user=u-man


open terminal type

sudo mkdir -p /home/u-man/Pictures/uman.com/

gedit   /home/u-man/Pictures/uman.com/index.html

and past the following


<html>
  <head>
    <title>Welcome to uman.com!</title>
  </head>
  <body>
    <h1>Success!  The uman.com virtual host is working!</h1>
  </body>
</html>
 

save it.

again type 

sudo mkdir -p /home/u-man/Pictures/anuj.borah.com/ 

sudo gedit  /home/u-man/Pictures/anuj.borah.com/index.html


<html>
  <head>
    <title>Welcome to anuj.borah.com!</title>
  </head>
  <body>
    <h1>Success!  The anuj.borah.com virtual host is working!</h1>
  </body>
</html>

save it

now

type it  cd /etc/apache2/sites/avai*

and then sudo gedit uman.com.conf

just past past the following


<VirtualHost uman.com>
ServerAdmin webmaster@localhost
ServerAlias www.uman.com
DocumentRoot /home/u-man/Pictures/uman.com/
#if using awstats
ScriptAlias /awstats/ /usr/lib/cgi-bin/
#we want specific log file for this server
CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>


again type sudo gedit anuj.borah.com.conf

and past the following

<VirtualHost anuj.borah.com>
ServerAdmin webmaster@localhost
ServerAlias www.anuj.borah.com
DocumentRoot /home/u-man/Pictures/anuj.borah.com/
#if using awstats
ScriptAlias /awstats/ /usr/lib/cgi-bin/
#we want specific log file for this server
CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>


now type  cd ..

cd sites-ena*


sudo ln /etc/apache2/sites-available/uman.com.conf uman.com.conf

sudo ln /etc/apache2/sites-available/anuj.borah.com.conf anuj.borah.com.conf


now type sudo gedit /etc/hosts

copy and past the following

127.0.0.1    localhost
127.0.0.2    uman.com
127.0.0.3    anuj.borah.com


now type sudo service apache2 restart

type uman.com  or anuj.borah.com  in your browser


bellow is the screen -shoot