Thursday, 28 April 2016

Batch script to clear browsing history, download history, and empty the cache for Chrome.

@echo off
set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"
cls
IF %ERRORLEVEL%==0 (
@echo "Success Message"
exit0
) ELSE (
@echo "Error Message"
exit 1001
)

Batch script to clear browsing history, download history, and empty the cache for Mozila Firefox.

:: Batch script to clear browsing history, download history, and empty the cache for Mozila Firefox.
:: Script can be run via GFI MAX RM
@echo off
set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
cls
IF %ERRORLEVEL%==0 (
@echo "Success Message"
timeout 10
) ELSE (
@echo "Error Message"
exit 1001
)

PowerShell Script to Clean History , Cashe and Downloads for Internet Explorer



$t_path_7 = "C:\Users\$env:username\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$c_path_7 = "C:\Users\$env:username\AppData\Local\Microsoft\Windows\Caches"
$d_path_7 = "C:\Users\$env:username\Downloads"

$temporary_path =  Test-Path $t_path_7
$check_cashe =    Test-Path $c_path_7
$check_download = Test-Path $d_path_7

if($temporary_path -eq $True -And $check_cashe -eq $True -And $check_download -eq $True)
{
    echo "Clean history"
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

    echo "Clean Temporary internet files"
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
    (Remove-Item $t_path_7\* -Force -Recurse) 2> $null
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

    echo "Clean Cashe"
    (Remove-Item $c_path_7\* -Force -Recurse) 2> $null

    echo "Clean Downloads"
    (Remove-Item $d_path_7\* -Force -Recurse) 2> $null

    echo "Done"
}



Friday, 22 April 2016

How to Test Your Internet Speed Bidirectionally from Command Line Using ‘Speedtest-CLI’ Tool

We always need to check the speed of the Internet connection at home and office. What we do for this? Go to websites like Speedtest.net and begin test. It loads JavaScript in the web browser and then select best server based upon ping and output the result. It also uses a Flash player to produce graphical results.
What about headless server, where isn’t any web based browser and the main point is, most of the servers are headless. The another bottleneck of such web browser based speed testing is that, you can’t schedule the speed testing at regular interval. Here comes an application “Speedtest-cli” that removes such bottlenecks and let you test the speed of Internet connection from command line.

What is Speedtest-cli

The application is basically a script developed in Python programming Language. It measures Internet Bandwidth speed bidirectionally. It used speedtest.net infrastructure to measure the speed. Speedtest-cli is able to list server based upon physical distance, test against specific server, and gives you URL to share the result of your internet speed test.
To install latest speedtest-cli tool in Linux systems, you must have Python 2.4-3.4 or higher version installed on the system.

Install speedtest-cli in Linux

There are two ways to install speedtest-cli tool. The first method involves the use of python-pip package while the second method is to download the Python script, make it executable and run, here I will cover both ways….

Install speedtest-cli Using pythin-pip

First you need to install python-pip package, then afterwards you can install the speedtest-cli tool using pip command as shown below.
$ sudo apt-get install python-pip
$ sudo pip install speedtest-cli
To upgrade speedtest-cli, at later stage, use.
$ sudo pip install speedtest-cli --upgrade

Install speedtest-cli Using Python Script

First download the python script from github using wget command, unpack the downloaded file (master.zip) and extract it..
$ wget https://github.com/sivel/speedtest-cli/archive/master.zip
$ unzip master.zip 
After extracting the file, go to the extracted directory speedtest-cli-master and make the script file executable.
$ cd speedtest-cli-master/
$ chmod 755 speedtest_cli.py 
Next, move the executable to /usr/bin folder, so that you don’t need to type the full path everytime.
$ sudo mv speedtest_cli.py /usr/bin/

Testing Internet Connection Speed with speedtest-cli

1. To test Download and Upload speed of your internet connection, run the speedtest-cli command without any argument as shown below.
$ speedtest_cli.py
2. To check the speed result in bytes in place of bits.
$ speedtest_cli.py --bytes
3. Share your bandwidth speed with your friends or family. You are provided with a link that can be used to download an image.
The following picture is a sample speed test result generated using above command.
4. Don’t need any additional information other than Ping, Download and upload?
$ speedtest_cli.py --simple
5. List the speedtest.net server based upon physical distance. The distance in km is mentioned.
$ speedtest_cli.py --list
6. The last stage generated a huge list of servers sorted on the basis of distance. How to get desired output? Say I only want to see the speedtest.net server located in Mumbai (India).
$ speedtest_cli.py --list | grep -i Mumbai
7. Test connection speed against a specific server. Use Server Id generated in example 5 and example 6 in above.
$ speedtest_cli.py --server [server ID]
$ speedtest_cli.py --server [5060]              ## Here server ID 5060 is used in the example.
8. To check the version number and help of speedtest-cli tool.
$ speedtest_cli.py --version
$ speedtest_cli.py --help
Note: Latency reported by tool is not its goal and one should not rely on it. The relative latency values output is responsible for server selected to be tested against. CPU and Memory capacity will influence the result to certain extent.

Conclusion

The tool is must for system administrators and developers. A simple script which runs without any issue. I must say that the application is wonderful, lightweight and do what it promises. I disliked Speedtest.net for the reason it was using flash, but speedtest-cli gave me a reason to love them.
speedtest_cli is a third party application and should not be used to automatically record the bandwidth speed. Speedtest.net is used by millions of users and it is a good idea to Set Your Own Speedtest Mini Server.
That’s all for now, till then stay tuned and connected to Tecmint. Don’t forget to give your valuable feedback in the comments below. Like and share us and help us get spread

Thursday, 21 April 2016

Install & configure Zimbra Open Source Mail Server on CentOS & RHEL

Install & configure Zimbra Open Source Mail Server on CentOS & RHEL
Overview:
Zimbra  is a Free Email Server and Calendar & collaboration solution, built for the both  public and private cloud . It is also considered an Exchange replacement. Zimbra provides a web GUI from where mailserver admin can manage zimbra server. Zimbra provides end users with a feature-rich browser-based experience that enables them to seamlessly and securely connect to their emails on any device or platform.
In this tutorial we will install & configure open source zimbra server on CentOS 6.X / RHEL 6.X. Before installating zimbra sever following prerequisite should be completed.
1. Create MX record for your domain
2. Create A record for your’s Hostname
In my case domain is “training.com” & Server’s Hostname is “mail.training.com”
Step:1 Install Necessary  Packages & update hosts file
# yum -y install nc wget nano make nc sudo sysstat libtool-ltdl glibc perl ntp
Edit the file /etc/hosts
x.x.x.x mail.training.com
Step:2 Stop Sendmail & postfix service if started & Disabled Selinux
# chkconfig sendmail off ; service sendmail stop ; chkconfig postfix off ; service  postfix stop ;
Disable selinux  in the file /etc/selinux/config change the selinux= line to SELINUX=disabled
Step:3 Download the Zimbra Server using below command
# wget http://files2.zimbra.com/downloads/8.0.4_GA/zcs-8.0.4_GA_5737.RHEL6_64.20130524120036.tgz
Step:4 Now extract Zimbra tar file using below command
# tar -zxpvf zcs-8.0.4_GA_5737.RHEL6_64.20130524120036.tgz
Step:5 Now Change the directory & run below command to install zimbra
# cd zcs-8.0.4_GA_5737.RHEL6_64.20130524120036
# ./install.sh  --platform-override
We are using ‘–platform-override‘ option in above command because installation script is only for Redhat  Linux but we are installing on CentOS 6.X machine so to override the Platform condition we are using this option. When we execute the above command we will get below output and follow the instructions :
Operations logged to /tmp/install.log.2570
Checking for existing installation...
zimbra-ldap...NOT FOUND
zimbra-logger...NOT FOUND
zimbra-mta...NOT FOUND
zimbra-snmp...NOT FOUND
zimbra-store...NOT FOUND
zimbra-apache...NOT FOUND
zimbra-spell...NOT FOUND
zimbra-convertd...NOT FOUND
zimbra-memcached...NOT FOUND
zimbra-proxy...NOT FOUND
zimbra-archiving...NOT FOUND
zimbra-cluster...NOT FOUND
zimbra-core...NOT FOUND
PLEASE READ THIS AGREEMENT CAREFULLY BEFORE USING THE SOFTWARE. ZIMBRA, INC..
License Terms for the Zimbra Collaboration Suite:
http://www.zimbra.com/license/zimbra_public_eula_2.1.html
Do you agree with the terms of the software license agreement? [N] Y
Do you agree with the terms of the software license agreement? [N] Y
License Terms for the Zimbra Collaboration Suite:
http://www.zimbra.com/license/zimbra_public_eula_2.1.html
Do you agree with the terms of the software license agreement? [N] Y
Do you agree with the terms of the software license agreement? [N] Y
Checking for prerequisites...
FOUND: NPTL
FOUND: nc-1.84-22
FOUND: sudo-1.8.6p3-12
FOUND: libidn-1.18-2
FOUND: gmp-4.3.1-7
FOUND: /usr/lib64/libstdc++.so.6
Checking for suggested prerequisites...
FOUND: perl-5.10.1
FOUND: sysstat
FOUND: sqlite
Prerequisite check complete.
Checking for installable packages
Found zimbra-core
Found zimbra-ldap
Found zimbra-logger
Found zimbra-mta
Found zimbra-snmp
Found zimbra-store
Found zimbra-apache
Found zimbra-spell
Found zimbra-memcached
Found zimbra-proxy
Select the packages to install
Install zimbra-ldap [Y] Y
Install zimbra-logger [Y] Y
Install zimbra-mta [Y] Y
Install zimbra-snmp [Y] Y
Install zimbra-store [Y] Y
Install zimbra-apache [Y] Y
Install zimbra-spell [Y] Y
Install zimbra-memcached [N] Y
Install zimbra-proxy [N] Y
Checking required space for zimbra-core
Checking space for zimbra-store
Installing:
zimbra-core
zimbra-ldap
zimbra-logger
zimbra-mta
zimbra-snmp
zimbra-store
zimbra-apache
zimbra-spell
zimbra-memcached
zimbra-proxy
The system will be modified.  Continue? [N] Y
Removing /opt/zimbra
Removing zimbra crontab entry...done.
Cleaning up zimbra init scripts...done.
Cleaning up /etc/ld.so.conf...done.
Cleaning up /etc/security/limits.conf...done.
Finished removing Zimbra Collaboration Server.
Installing packages
zimbra-core......zimbra-core-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-ldap......zimbra-ldap-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-logger......zimbra-logger-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-mta......zimbra-mta-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-snmp......zimbra-snmp-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-store......zimbra-store-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-apache......zimbra-apache-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-spell......zimbra-spell-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-memcached......zimbra-memcached-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
zimbra-proxy......zimbra-proxy-8.0.4_GA_5737.RHEL6_64-20130524120036.x86_64.rpm...done
Operations logged to /tmp/zmsetup.12152013-081656.log
Installing LDAP configuration database...done.
Setting defaults...
DNS ERROR resolving MX for mail.training.com
It is suggested that the domain name have an MX record configured in DNS
Change domain name? [Yes] Yes
Create domain: [mail.training.com] nextstep4itmail.com                                           
MX: mail.training.com (162.13.151.48)
Interface: 162.13.151.48
Interface: 2a00:1a48:7807:102:c7d4:45f6:ff08:2209
Interface: 10.181.72.68
Interface: 127.0.0.1
Interface: ::1
done.
Step:6 Next you will come to the Main Menu which will show your configuration. Select #3 then change the Admin Password under option #4 next hit r to go back.
*** CONFIGURATION COMPLETE - press 'a' to apply
Select from menu, or press 'a' to apply config (? - help) a
Save configuration data to a file? [Yes] Yes
Save config in file: [/opt/zimbra/config.10975]
Saving config in /opt/zimbra/config.10975...done.
The system will be modified - continue? [No] Yes
Operations logged to /tmp/zmsetup.12152013-081656.log
Setting local config values...
When Configuration complete – press return to exit. Now the zimbra installation is completed.
Step:7 Access web administration console
Use the URL ‘https://<Server’s HostName>:7071′
In my case URL is “https://mail.training.com:7071”
Use the User Name as admin and Password that we have set while installation in the above steps.

After entering the credential, we will get the below Admin Console from where mail admin can monitor and can perform the tasks like creating users a, setting quota for users & reset their password & much more…

Step:8 End Users can access their mails via Web
Use the the URL “https://mail.training.com”, replace the hostname according to your setup. After entering the  the credentials, end users will get the below console from where they can send & receive emails.

Note : Use zmcontrol Command to  stop, start & to check Status of zimbra Server
[root@zimbra ~]# su - zimbra
[zimbra@zimbra ~]$ zmcontrol status
[zimbra@zimbra ~]$ zmcontrol stop
[zimbra@zimbra ~]$ zmcontrol start

Friday, 1 April 2016

Adding Static Routes On Various *NIX (Linux,AIX,HP-UX)


Adding Static Routes On Various *NIX (Linux,AIX,HP-UX)

 

Overview:

Static routes are generally required for traffic that must not, or should not, go through the default gateway. In this article we will discuss how to add static routes in various nix.

Scenario: Suppose if you want that all the traffic to network 172.168.102.0/24 should use 172.168.101.1 as gateway. This can be done by adding a static route in the kernel routing table as shown below.

Adding Static Route in Linux from the Command line :

# route add -net 172.168.102.0 netmask 255.255.255.0 gw 172.168.101.1 dev eth0

OR

# ip route add 172.168.102.0/24 via 172.168.101.1 dev eth0

Above Commands will make changes to the routing table temporary and not permanent. Use any of below mention command To check Routing tables in Linux :

# route -n

# netstat -nr

Steps to make the static Route Persistent Across the reboot :

In case of RHEL5.X / CentOS 5.X

Create a file  route file

# vi /etc/sysconfig/network-scripts/route-eth0

172.168.102.0/24 via 172.168.101.1 dev eth0

Save and close the file and  Restart network service

# service network restart

In case of RHEL6.X / CentOS 6.X

# vi /etc/sysconfig/network-scripts/route-eth0

GATEWAY0= 172.168.101.1

NETMASK0=255.255.255.0

ADDRESS0= 172.168.102.0

Save and close the file and  Restart network service

# service network restart

Adding Static Routes in AIX :

Step:1 Go to the SMITTY menu for routes

Step:2 Select Type of route ‘net’ or ‘host’ ( if default route then leave set to ‘net’ )

Step:3 Enter  the destination address.

Step:4 Enter the gateway address ( on the line that “* default GATEWAY Address”)

Step:5 If a ‘net’ or default route , enter the ‘Network Mask’ , if host  do not set ‘Network Mask’

Step:6 Enter the network interface for this route. To select from the list arrow down to the ‘Network Interface’ line and hit[F4] or [ESC]+ [4]   to display list of available interfaces.

Step:7 Hit [ENTER] TO APPLY . You should recieve a return status of “OK”

Step:8 To exit the smitty , type  [F10] or [0]

Step:9 Verify that your routes have been configured

# netstat -nr | grep UG

Adding Static Route in HP-UX

Step:1 Make a backup copy of ‘/etc/rc.config.d/netconf

Step:2 Add a stanza  to /etc/rc.config.d/netconf for the new route . Make sure you use a new array number for the stanza

Example : Replace ‘nn’ with the next number in the list.

ROUTE_DESTINATION[nn]="IP-of-NewHost"

ROUTE_MASK[nn]=" "

ROUTE_GATEWAY[nn]="IP-of-Router"

ROUTE_COUNT[nn]=""

ROUTE_ARGS[nn]=""

Save  & Close the file

Step:3 Now run the below command to re-read the netconf file and add the route

# /sbin/init.d/net start

Note: Run the above command with start option only because it will add new route without effecting existing network configuration.