October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

start/stop asterisk

To start asterisk server
/usr/sbin/asterisk

To stop asterisk server
/usr/sbin/asterisk -r
CLI>stop now

To reload asterisk server
CLI>reload

To restart asterisk server
CLI>restart now

asterisk –rx “stop now”

To show version

asterisk -rx “core show version”

 

asterisk –rx “core show translation”

asterisk –rx “core show codecs”

 

YUM Server in CentOS 6.x / RHEL 6.x

Setup Local YUM Server in CentOS 6.x / RHEL 6.x

(Yum) is a software package manager that installs, updates and removes packages on RPM-based Linux distributions. Yum makes it easier to maintain groups of machines without having to manually update each one using rpm.

Features:

Support for multiple repositories.
Simple configuration.
Automatic dependency calculation.
Fast operation.
RPM-consistent behavior.
Package group support, including multiple-repository groups.
Simple interface.
Yum uses an online repository by default, but you can also configure it to use a local repository of packagesY
Let us install a local yum server using CentOS 6.3. The steps provided here are tested in CentOS 6.3. But it will work fine in RHEL 6.x and Scientific Linux 6.x too.

Install CentOS 6.3 as a physical or virtual machine. I have already covered a topic how to install Redhat Enterprise Linux 6.0 earlier in this blog. Those steps are damn similar to CentOS 6.x and Scientific Linux 6.x installation. So just follow the steps exactly to install CentOS 6.3.

In this example the hostname of the server is rmohan.com and IP Address is 192.168.56.101.

Login to your system and Mount the contents of your CentOS 6.3 DVD in the /mnt directory or wherever you want. In the Terminal window, type the following command:
# mount /dev/cdrom1 /mnt/ (Here cdrom1 is my local cdrom device)

Install vsftpd package, so that we can use this as a FTP server to share our repository in the client systems.
Change to the directory where you mounted CentOS DVD. In our example we have mounted the CentOS DVD in /mnt directory.
# cd /mnt/Packages
# rpm -ivh vsftpd-2.2.2-11.el6.i686.rpm

Start the FTP Service:
# service vsftpd start

Install createrepo package if it is not installed. This is package is used to create our local repository.
# rpm -ivh createrepo-0.9.8-5.el6.noarch.rpm

Then install the another one:
# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm

Now install the createrepo package:

Create a folder called localyumserver (You can use your own) in /var/ftp/pub directory to save all the packages from the CentOS DVD. Copy all the files in the Packages folder from the DVD to /var/ftp/pub/localyumserver folder:
# mkdir /var/ftp/pub/localyumserver
# cp -ar *.* /var/ftp/pub/localyumserver

It will take a while to copy all the packages in the DVD. Please be patient. After all packages are copied, create a repo file called localyumserver.repo in /etc/yum.repos.d/ directory.
# nano /etc/yum.repos.d/localyumserver.repo

Type the following entries and save the file (CTRL+O to save and CTRL+X to exit):

Where,
[localyumserver] ==> Name of the Local Repository.
comment ==> Information about the Repository.
baseurl ==> Path of the Repository (i.e where we had copied the contents from CentOS DVD)
gpgcheck ==> Authentication of the Repository, which is disabled in our case.

Now it is time to create our repository. Enter the following command in the Terminal:
# createrepo -v /var/ftp/pub/localyumserver
Now the local YUM repository creation process will begin.

Note: Delete or rename all the other repo files except the newly created repo file i.e in our example it is localyumserver.repo.

Next update the repository:
yum clean all
yum update
You’re done now.

Client side configuration:

Create a repo file in your client system as mentioned above in the /etc/yum.repos.d/ directory and remove or rename the existing repositories. Then modify the baseurl as mentioned below:

[localyumserver]
comment =”My Local Repository”
baseurl=ftp://rmohan.com/pub/localyumserver
gpgcheck=0
enabled=1
(or)

[localyumserver]
comment =”My Local Repository”
baseurl=ftp://192.168.56.101/pub/localyumserver
gpgcheck=0
enabled=1

Thats it. Start using Yum. Enjoy!!

Bind Chroot

Setup DNS Server step by step in CentOS 6.3 / RHEL 6.3

DNS (Domain Name System) is the core component of network infrastructure. The DNS service resolves hostname into ip address and vice versa. For example if we type http://www.rmohan.com in browser, the DNS server translates the domain name into its corresponding ip address. So it makes us easy to remember the domain names instead of its ip address.

DNS Server Installation in CentOS 6.3:

This how-to tutorial will shows you how to install and configure DNS server. In this scenario my dns server FQDN (Fully Qualified Domain Name) and
ip-address are webserver.rmohan.com and 192.168.1.100 respectively. The steps provided here are tested in CentOS 6.3, but it should work in RHEL 6.x(x stands for version) and Scientific Linux 6.x too.

Prerequisites:

Before proceed, check the following properly.

1. Check FQDN (Fully Qualified Name) of the server.

[root@webserver ~]# hostname
webserver.rmohan.com
2. Check IP Address of the Server.

[root@webserver ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:1B:84:3A
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe1b:843a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7785 errors:0 dropped:0 overruns:0 frame:0
TX packets:3635 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:729396 (712.3 KiB) TX bytes:461240 (450.4 KiB)
3. Enter the resolver IP (DNS Server IP i.e 192.168.1.100 in our example) in /etc/resolv.conf file.

[root@webserver ~]# nano /etc/resolv.conf
# Generated by NetworkManager
search rmohan.com
nameserver 192.168.1.100
4. Disable Firewall.

[root@webserver ~]# service iptables stop
[root@webserver ~]# chkconfig iptables off
[root@webserver ~]# service ip6tables stop
[root@webserver ~]# chkconfig ip6tables off
5.Disable selinux.

Set SELINUX=disabled to disable the Selinux in the /etc/selinux/config file..
[root@webserver ~]# nano /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
Reboot the server to save the changes.

6.Check Firewall and Selinux Status:

[root@webserver ~]# service iptables status
iptables: Firewall is not running.
[root@webserver ~]# service ip6tables status
ip6tables: Firewall is not running.
[root@webserver ~]# sestatus
SELinux status: disabled
Well, all the services are disabled now.
Install bind9 package:

[root@webserver ~]# yum install bind*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
localrepo | 1.3 kB 00:00 …
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package bind.i686 32:9.8.2-0.10.rc1.el6 will be installed
–> Processing Dependency: portreserve for package: 32:bind-9.8.2-0.10.rc1.el6.i686
—> Package bind-chroot.i686 32:9.8.2-0.10.rc1.el6 will be installed
—> Package bind-devel.i686 32:9.8.2-0.10.rc1.el6 will be installed
—> Package bind-dyndb-ldap.i686 0:1.1.0-0.9.b1.el6 will be installed
—> Package bind-libs.i686 32:9.8.2-0.10.rc1.el6 will be installed
—> Package bind-sdb.i686 32:9.8.2-0.10.rc1.el6 will be installed
–> Processing Dependency: libpq.so.5 for package: 32:bind-sdb-9.8.2-0.10.rc1.el6.i686
—> Package bind-utils.i686 32:9.8.2-0.10.rc1.el6 will be installed
–> Running transaction check
—> Package portreserve.i686 0:0.0.4-9.el6 will be installed
—> Package postgresql-libs.i686 0:8.4.11-1.el6_2 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
===================================================
Package Arch Version Repository Size
===================================================
Installing:
bind i686 32:9.8.2-0.10.rc1.el6 localrepo 4.0 M
bind-chroot i686 32:9.8.2-0.10.rc1.el6 localrepo 70 k
bind-devel i686 32:9.8.2-0.10.rc1.el6 localrepo 375 k
bind-dyndb-ldap i686 1.1.0-0.9.b1.el6 localrepo 63 k
bind-libs i686 32:9.8.2-0.10.rc1.el6 localrepo 881 k
bind-sdb i686 32:9.8.2-0.10.rc1.el6 localrepo 305 k
bind-utils i686 32:9.8.2-0.10.rc1.el6 localrepo 180 k
Installing for dependencies:
portreserve i686 0.0.4-9.el6 localrepo 22 k
postgresql-libs i686 8.4.11-1.el6_2 localrepo 201 k
Transaction Summary
===================================================
Install 9 Package(s)
Total download size: 6.0 M
Installed size: 13 M
Is this ok [y/N]: y
Downloading Packages:
——————————————————————————–
Total 16 MB/s | 6.0 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : 32:bind-libs-9.8.2-0.10.rc1.el6.i686 1/9
Installing : portreserve-0.0.4-9.el6.i686 2/9
Installing : 32:bind-9.8.2-0.10.rc1.el6.i686 3/9
Installing : postgresql-libs-8.4.11-1.el6_2.i686 4/9
Installing : 32:bind-chroot-9.8.2-0.10.rc1.el6.i686 5/9
Installing : 32:bind-devel-9.8.2-0.10.rc1.el6.i686 6/9
Installing : 32:bind-sdb-9.8.2-0.10.rc1.el6.i686 7/9
Installing : bind-dyndb-ldap-1.1.0-0.9.b1.el6.i686 8/9
Installing : 32:bind-utils-9.8.2-0.10.rc1.el6.i686 9/9
Verifying : 32:bind-utils-9.8.2-0.10.rc1.el6.i686 1/9
Verifying : 32:bind-chroot-9.8.2-0.10.rc1.el6.i686 2/9
Verifying : 32:bind-devel-9.8.2-0.10.rc1.el6.i686 3/9
Verifying : postgresql-libs-8.4.11-1.el6_2.i686 4/9
Verifying : 32:bind-sdb-9.8.2-0.10.rc1.el6.i686 5/9
Verifying : portreserve-0.0.4-9.el6.i686 6/9
Verifying : 32:bind-9.8.2-0.10.rc1.el6.i686 7/9
Verifying : 32:bind-libs-9.8.2-0.10.rc1.el6.i686 8/9
Verifying : bind-dyndb-ldap-1.1.0-0.9.b1.el6.i686 9/9
Installed:
bind.i686 32:9.8.2-0.10.rc1.el6 bind-chroot.i686 32:9.8.2-0.10.rc1.el6
bind-devel.i686 32:9.8.2-0.10.rc1.el6 bind-dyndb-ldap.i686 0:1.1.0-0.9.b1.el6
bind-libs.i686 32:9.8.2-0.10.rc1.el6 bind-sdb.i686 32:9.8.2-0.10.rc1.el6
bind-utils.i686 32:9.8.2-0.10.rc1.el6
Dependency Installed:
portreserve.i686 0:0.0.4-9.el6 postgresql-libs.i686 0:8.4.11-1.el6_2
Complete!
Configuration:

The main configuration of the DNS will look like below. Edit and add the entries below which are marked as bold in this configuration files.

[root@webserver ~]# nano /etc/named.conf
//
// 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 { 127.0.0.1; 192.168.1.100; };
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 { localhost; 192.168.1.0/24; };
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”;
};
logging {
channel default_debug {
file “data/named.run”;
severity dynamic;
};
};
zone “.” IN {
type hint;
file “named.ca”;
};
zone “rmohan.com” IN {
type master;
file “fwd.rmohan.com”;
allow-update { none; };
};
zone “1.168.192.in-addr.arpa” IN {
type master;
file “rev.rmohan.com”;
allow-update { none; };
};
include “/etc/named.rfc1912.zones”;
include “/etc/named.root.key”;
Create Zone files:

Now we should create forward and reverse zone files which we mentioned in the /etc/named.conf file.
Create Forward Zone:

Create fwd.rmohan.com file in the /var/named directory and add the entries for forward zone as shown below.

[root@webserver ~]# nano /var/named/fwd.rmohan.com
$TTL 86400
@ IN SOA webserver.rmohan.com. root.rmohan.com. (
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
IN NS webserver.rmohan.com.
IN A 192.168.1.100
webserver IN A 192.168.1.100
Save and exit the file by pressing the keys CTRL+O and CTRL+X.

Create Reverse Zone:

Create rev.rmohan.com file in the /var/named directory and add the entries for reverse zone as shown below.

[root@webserver ~]# nano /var/named/rev.rmohan.com
$TTL 86400
@ IN SOA webserver.rmohan.com. root.rmohan.com. (
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
IN NS webserver.rmohan.com.
IN PTR rmohan.com.
IN A 255.255.255.0
100 IN PTR webserver.rmohan.com.
Save and exit by pressing the keys CTRL+O and CTRL+X.

Start the bind service.

[root@webserver ~]# service named start
Generating /etc/rndc.key: [ OK ]
Starting named: [ OK ]
[root@webserver ~]# chkconfig named on
Test DNS Server:

[root@webserver ~]# dig webserver.rmohan.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> webserver.rmohan.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 217
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;webserver.rmohan.com. IN A
;; ANSWER SECTION:
webserver.rmohan.com. 86400 IN A 192.168.1.100
;; AUTHORITY SECTION:
rmohan.com. 86400 IN NS webserver.rmohan.com.
;; Query time: 3 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Fri Jan 25 16:50:45 2013
;; MSG SIZE rcvd: 72
[root@webserver ~]# dig -x 192.168.1.100
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> -x 192.168.1.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3272
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;100.1.168.192.in-addr.arpa. IN PTR
;; ANSWER SECTION:
100.1.168.192.in-addr.arpa. 86400 IN PTR webserver.rmohan.com.
;; AUTHORITY SECTION:
1.168.192.in-addr.arpa. 86400 IN NS webserver.rmohan.com.
;; ADDITIONAL SECTION:
webserver.rmohan.com. 86400 IN A 192.168.1.100
;; Query time: 4 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Fri Jan 25 16:52:13 2013
;; MSG SIZE rcvd: 112
If you get all the four sections QUESTION, ANSWER, AUTHORITY, ADDITIONAL as 1, you’re done. Otherwise check the steps again for any mistakes.

Thats it. Have a good day!!!

db2 tcp ip bindings

Enable DB2 service ports for remote connections.

To enable outside users to get to your DB2 databases, you’ll need to set up the DB2 service port, as it is not configured by the Synaptic installation process.

As the regular user, run sudo vi /etc/services and add this line to the end of the file and save the changes:

db2c_db2inst1       50001/tcp        # IBM DB2 instance - db2inst1

Then, as the DB2 instance owner (db2inst1 by default), run these commands:

db2 update dbm cfg using SVCENAME db2c_db2inst1
db2set DB2COMM=tcpip
db2stop
db2start

iptables Rules

Block IP traffic from an specific IP or Network.

Block from an IP

iptables -A INPUT -s 11.22.33.44 -j DROP

If you want to block only on an specific NIC

iptables -A INPUT -s 11.22.33.44 -i eth0 -j DROP

Or an specific port

iptables -A INPUT -s 11.22.33.44 -p tcp -dport 22 -j DROP

Using a Network and not only one IP

iptables -A INPUT -s 11.22.33.0/24 -j DROP

Block traffic from a specific MAC address

Suppose you want to bloc traffic some a MAC address instead of an IP address. This is handy if a DHCP server is changing the IP of the maching you want to protect from.

iptables -A INPUT -m mac --mac-source 00:11:2f:8f:f8:f8 -j DROP

Block a specific port

If all you want is to block a port, iptables can still do it.

And you can block incoming or outgoing traffic.

Block incoming traffic to a port

Suppose we need to block port 21 for incoming traffic:

iptables -A INPUT -p tcp --destination-port 21 -j DROP

But if you have two-NIC server, with one NIC facing the Internet and the other facing your local private Network, and you only one to block FTP access from outside world.

iptables -A INPUT -p tcp -i eth1 -p tcp --destination-port 21 -j DROP

In this case I’m assuming eth1 is the one facing the Internet.

You can also block a port from a specific IP address:

iptables -A INPUT -p tcp -s 22.33.44.55 --destination-port 21 -j DROP

Or even block access to a port from everywhere but a specific IP range.

iptables -A INPUT p tcp -s ! 22.33.44.0/24 --destination-port 21 -j DROP

Block outgoing traffic to a port

If you want to forbid outgoing traffic to port 25, this is useful, in the case you are running a Linux firewall for your office, and you want to stop virus from sending emails.

iptables -A FORWARD -p tcp --dport 25 -j DROP

I’m using FORWARD, as in this example the server is a firewall, but you can use OUTPUT too, to block also server self traffic.

Log traffic, before taking action

If you want to log the traffic before blocking it, for example, there is a rule in an office, where all employees have been said not to log into a given server, and you want to be sure everybody obeys the rule by blocking access to ssh port. But, at the same time you want to find the one who tried it.

iptables -A INPUT -p tcp --dport 22 -j LOG --log-prefix "dropped access to port 22" iptables -A INPUT -p tcp --dport 22 -j DROP

You will be able to see which IP tried to access the server, but of course he couldn’t.

Tips and Tricks

Because iptables executes the rules in order, if you want to change something you need to insert the rule in the specific position, or the desired effect is not going to be achieved.

List rules with numbers

iptables -nL --line-numbers

This is going to list all your rules with numbers preceding the rules. Determine where you want the inserted rule and write:

List specific chains

iptables -nL INPUT

Will list all INPUT rules.

iptables -nL FORWARD

Will list all OUTPUT rules

Insert rules

iptables -I INPUT 3 -s 10.0.0.0/8 -j ACCEPT

That is going to add a rule in position 3 of the “array”

Delete rules

iptables -D INPUT 3

That is going to remove the rule inserted above. You can also remove it, by matching it.

iptables -D INPUT -s 10.0.0.0/8 -j ACCEPT

Delete flush all rules and chains

This steps are very handy if you want to start with a completely empty and default tables:

iptables --flush iptables --table nat --flush iptables --table mangle --flush iptables --delete-chain iptables --table nat --delete-chain iptables --table mangle --delete-chain

NOTE: do not execute this rules if you are connected via ssh or something similar, you may get locked out

Simple scripts for specific needs

How to stop brute force attacks

You can also use iptables to stop brute force attacks to your server, for example: Allow only three attempts to log through ssh before banning the IP for 15 minutes, this should let legitimate users to log to the servers, but bots will not be able. Remember to always use strong passwords

iptables -F iptables -A INPUT -i lo -p all -j ACCEPT iptables -A OUTPUT -o lo -p all -j ACCEPT iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -p tcp --dport ssh -j ACCEPT iptables -A INPUT -p tcp --dport www -j ACCEPT iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 900 --hitcount 3 -j DROP iptables -P INPUT DROP

How to NAT with iptables

iptables is also very useful to configure NAT routers, a Linux mashing can act as a router, and share its public IP with a private networks behind it. It is also useful to configure the DHCP in the same server.

To configure a NAT router, you will be better with a server with two NICs, let’s suppose you have:

  • eth0: 12.13.14.15
  • eth1: 10.1.1.1

Now configure NAT to forward all traffic from 10.1.1.0 network through eth0 IP. You may want to empty all tables and start with a fresh chains and tables (see how above).

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE iptables --append FORWARD --in-interface eth1 -j ACCEPT

That is it, you only have to enable kernel forwarding now:

echo 1 > /proc/sys/net/ipv4/ip_forward

Forwarding Email to another host via Qmail

Today I needed to relay/forward all Email from one Server (Server A) to another Server (Server B). Server A is running Qmail (on CentOS). Server B is running company smartermail.

After googling and searching, I found a site teaches “forwarding Email to another host” using Qmail. I tried, as the article recommends setting up a Qmail config file (which didn’t existed):

/var/qmail/control/smtproutes

Containing a Qmail Email domain forwarding rule:

[domain.com]:[ip address]

So If you are running Plesk Parallel Panel, Qmail was being run with virtual domain support and spotted a Qmail config file:

/var/qmail/control/virtualdomains

This config file contained the name of the domain I was trying to forward followed by a colon and a number, Must remove the line containing the domain name trying to forward, then restart the Qmail.

These are what you need to do, the process are:

#1. Back up all your current, working config files and if at all possible, do this using a test domain or sub-domain name so if you make mistakes you have a backup!

#2. Set up your destination Email Server to receive Email for the relevant (sub)domain and Email account(s).

#3. Ensure that the domain name you are trying to forward Email for is in the Qmail config file /var/qmail/control/rcpthosts (this ensures that Qmail will handle Email for the domain).

#4. A necessary to create the Qmail config file /var/qmail/control/smtproutes.
Add a forwarding rule to /var/qmail/control/smtproutes

[domain.com]:[ip address]

If you want to forward all Email for all domains handled by your Qmail Server, you can use a wildcard config which means you omit the source domain name e.g.:

:[ip address]

#5. Now you can restart Qmail:

$ /etc/rc.d/init.d/qmail restart

#6. Check your destination Email Server which should now be receiving Email sent to Server A for the source domain.

This worked fine for me using (source server) Centos/Fedora/Plesk 8,10,11/Qmail and destination server smartermail/Postfix.

Resetting MySQL Root Password: Red Hat and CentOS

If you’ve forgotten your MySQL root password (or are involved with some nefarious activity), here is how you can reset that password on a Red Hat (RHEL) system or a CentOS system:

Stop MySQL:

root#  service mysqld stop

Start MySQL in safe mode:

root#  mysqld_safe –skip-grant-tables &

Log into MySQL as root:

root#  mysql -u root

Reset the password:

mysql>  update mysql.user set password=PASSWORD(“YourNewPassW0RD”) where User=’root’;

mysql>  flush privileges; exit;

Log out of MySQL and stop the Safe Mode:

root#  service mysqld stop

Start MySQL in the normal mode:

root#  service mysqld start

Log into MySQL with your new password:

root#  mysql -u root -p

Enter password:

mysql>

Resetting MySQL Root Password: Debian or Ubuntu

 

If you’ve forgotten your MySQL root password (or are involved with some nefarious activity), here is how you can reset that password on a Debian GNU/Linux system or an Ubuntu GNU/Linux system:

Find out the account that the system uses to start and stop MySQL (note that I’ve changed the password for this demo):

root#  cat /etc/mysql/debian.cnf

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = 11223344554433
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user     = debian-sys-maint
password = 11223344554433
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

Log into MySQL with that account:

root#  mysql -u debian-sys-maint -p

Enter password:

mysql>

Change the password:

mysql>  update mysql.user set password=PASSWORD(“YourNewPassW0RD”) where User=’root’;

mysql>  flush privileges; exit;

Log into MySQL as root with your new password:

root#  mysql -u root -p

Enter password:

mysql>

7zip

zip is a nice, cross-platform compression software, similar in purpose to WinZip or GZip.  &zip can create and extract those .zip and .gz (and tar.gz) files, but it uses LZMA for its own native compression, which is a much more modern compression format.  (if you’re using .rar, please stop already).

 
Use 7zip to create a password-protected file of a list of files and directories; note the flags -p -mhe which are REQUIRED for the password part to function!  7zip uses AES encryption with 256-bit keys, so this encryption isn’t joking around.
 
Some basic command-line examples for using 7zip are listed below, which is run with either 7z or 7za on a GNU/Linux system, the 7za being a bit less capable but also has fewer dependencies.
 
To Archive the files and folders ‘test/ test2/ file1 file2’
shell$ 7z a -t7z -p -mhe out-file.7z test/ test2/ file1 file2
Scanning
Updating archive out-file.7z
Enter password (will not be echoed) :
Verify password (will not be echoed) :
Everything is Ok
 
To List the files:
shell$ 7z l out-file.7z
 
And to Extract the files:
shell$ 7z e out-file.7x
 
 
More Details :   http://www.dotnetperls.com/7-zip-examples
 
 
 

Openssl Howto for Apache

 

Display Certificate Subject name in readable format

openssl x509 -in CERTIFICATE_FILE -noout -subject -nameopt multiline,-lname,-align

Top

To verify a certificate chain

openssl verify CERTIFICATE_FILE

 

The file CERTIFICATE_FILE contain the intermediate certificate first and the servers certificate.

Check your Certificate using the Certificate Check tool at the bottom of the page

Top

To view a PKCS#12 file using openssl command

openssl pkcs12 -in CertName.p12

A PKCS#14 file contains the certificate, private key and all the intermediate certificate’s in a certificate chain and is encrypted with a password.

Alternatively use PKCS12 view Tool

Top

Convert PKCS#12 file to pem format using openssl command

openssl x509 -inform der -in certname.p12 -out convertedfile

Top

To view PKCS#7 files using openssl command

The PKCS #7 format enables the transfer of a certificate and all the certificates in its certification path from one computer to another, or from a computer to removable media. PKCS #7 files typically use the .p7b extension, and are compatible with the ITU-T X.509 standard

openssl pkcs7 -in filename_containing_cert -print_certs -out cert.pem

Top

Convert a PKCS#7 file from PEM to DER using openssl command

command: openssl pkcs7 -in filename_containing_cert -outform DER -out file.der

Top

Convert a DER formatted certificate to PEM using openssl command

openssl x509 -inform der -in certificate_file -outform pem -out newfilename.pem

To view the Der formatted file (*.crt, *.cer, *.der)
openssl x509 -inform der -in certificate_file -text Top

Display Certificate Thumbprint

To display certificate thumbprint using open source software namely openssl

1. openssl x509 -in CERTIFICATE_FILE -noout -sha1 -fingerprint
2. openssl x509 -in CERTIFICATE_FILE -noout -fingerprint

OpenSSL Commands to Convert SSL Certificates on Your Machine

Convert PEM to DER

openssl x509 -outform der -in certificate.pem -out certificate.der

Convert PEM to P7B

openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer

Convert PEM to PFX

openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

OpenSSL Convert DER

Convert DER to PEM

openssl x509 -inform der -in certificate.cer -out certificate.pem

OpenSSL Convert P7B

Convert P7B to PEM

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

Convert P7B to PFX

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer

OpenSSL Convert PFX

Convert PFX to PEM

openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes