Wednesday, 18 June 2014

Sending mail from CentOS

Actually sending mail from a CentOS server/Desktop install is pretty easy. You can do that in many ways but I like this way because it is simpler.

Before sending the mail, the content of your mail if you store at some place would be better. assume like I have stored my message /tmp/body file.

Then I will sent my message as

mail -s "This is subject of message" raja@raja.com < /tmp/message

thats it. check for your mail in inbox/spam/junk box.

Create Bootable Linux ISO from DD command


I have tried many times to create a Bootable USB linux from ISO but failed almost 20 times. After a lot of googling I have found as this is the proper command

dd if=/path/to/ISO.iso of=/dev/sda bs=4M;sync

Thats it. Note: at of=/dev/sda dont give anything after your device. for example If your USB mounted as /dev/sdb1 then at of you should give as of=/dev/sdb only.

Tuesday, 20 May 2014

Set brightness from terminal


Set Screen Brightness from Terminal

We can set screen brightness from terminal by using xbacklight. Intially we have to install it before using. Open your terminal and type as

sudo apt-get install xbacklight

and then to set brightness to 10% more execute the command as

xbacklight -inc 10

To decrease brightness by 10%

xbacklight -dec 10

If you want to set the brightness to some level then, you can use the command as

xbacklight -set 50

The above command will set the brightness to 50. It will range from 0 to 100.
If you have any issues you can use comments to let me know.
Hope that helps.

I have decided to post my best Question and Answers from Ask Ubuntu. All these Questions and answers are posted by me.
My User Id of Ask Ubuntu is Raaz

Sunday, 11 May 2014

How to Download Total website by using Wget


How to Download Total website by using Wget


If you would like to download a whole website pages then you can do it wget.
wget is a command-line download manager,installed by default in almost all linux operating systems.
Syntax

wget -rkp -l3 -np -nH --cut-dirs=1 [URL]



Example

wget -rkp -l3 -np -nH --cut-dirs=1 http://ss64.com/bash/aspell.html

Wednesday, 30 April 2014

IPTABLES GUIDE


***** SAMPLE DEFAULT IPTABLES file************************

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p UDP -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

***********************************************************************





********************IPTABLES Command line Examples ********************************************



Drop all Incoming ICMP
----------------------
iptables -A INPUT -p ICMP --icmp-type 8 -j DROP


Drop all Outgoing ICMP
-----------------------
iptables -A OUTPUT -p icmp --icmp-type echo-request -j DROP


Allow ICMP from a specific host
--------------------------------
iptables -A INPUT -s
XXX.XXX.XXX.XXX -p ICMP --icmp-type 8 -j ACCEPT


Allow all UDP traffic
---------------------
iptables -A INPUT -p udp -j ACCEPT


Allow range of UDP ports
------------------------
iptables -A INPUT -p udp -m state --state NEW -m multiport --dports 40000:60000 -j ACCEPT


Allow SNMP form a particular source
XXX.XXX.XXX.XXX/24
-----------------------------------------------------

iptables -A INPUT -p udp -s XXX.XXX.XXX.XXX/24 --sport 1024:65535 --dport 161:162 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp --sport 161:162 -d
XXX.XXX.XXX.XXX/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

*Following is optional. It is required only when the default OUTPUT chain policy is set to DROP or REJECT
iptables -A OUTPUT -p udp --sport 161:162 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT


**************************************************************************************************************************************


**********************Sample IP Tables File after applying rules ************************************************************************
-------------------------

# Generated by iptables-save v1.4.7 on Thu Apr 24 14:51:47 2014
*filter
:INPUT ACCEPT [0:0] --> Set default INPUT chain Policy to ACCEPT
:FORWARD ACCEPT [0:0] --> Set default FORWARD chain Policy to ACCEPT
:OUTPUT ACCEPT [1771:96518] --> Set default FORWARD chain Policy to ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --> Initially allow all INPUT traffic from all
-A INPUT -i lo -j ACCEPT --> ACCEPT all incoming traffic on loopback interface from all
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8595 -j ACCEPT --> ACCEPT custom SSH TCP port 8585 from all
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT --> ACCEPT default HTTP TCP port 80 from all
-A INPUT -s
XXX.XXX.XXX.XXX/32 -p icmp -m icmp --icmp-type 8 -j ACCEPT --> ACCEPT ICMP ping requests from the specific host/ipaddress
XXX.XXX.XXX.XXX

 -A INPUT -s XXX.XXX.XXX.XXX/32 -p icmp -m icmp --icmp-type 8 -j ACCEPT --> ACCEPT ICMP ping requests from the specific host/ipaddress XXX.XXX.XXX.XXX
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT --> ACCEPT secondary HTTP TCP port 8080 from all
-A INPUT -p udp -m udp --dport 5060 -j ACCEPT --> ACCEPT custom media UDP port 5060 from all
-A INPUT -p udp -m state --state NEW -m multiport --dports 40000:60000 -j ACCEPT --> ACCEPT all custom media UDP port numbers within the range 40000 to 60000 from all
-A INPUT -s
XXX.XXX.XXX.XXX/32 -j ACCEPT --> ACCEPT any kind of traffic comming from specific host/ipaddress
XXX.XXX.XXX.XXX

 -A INPUT -s XXX.XXX.XXX.XXX/24 -p udp -m udp --sport 1024:65535 --dport 161:162 -m state --state NEW,ESTABLISHED -j ACCEPT --> Allow SNMP requests comming from the specific network XXX.XXX.XXX.XXX/24 originationg from the ports with in the rage 1024 to 65535 destined to 161 and 162
-A INPUT -s
XXX.XXX.XXX.XXX/24 -p icmp -m icmp --icmp-type 8 -j ACCEPT --> ACCEPT ICMP ping requests from the specific network XXX.XXX.XXX.XXX/24
-A INPUT -p icmp -m icmp --icmp-type 8 -j DROP --> DROP (Deny without a message) ping request from rest all
-A INPUT -j REJECT --reject-with icmp-host-prohibited --> REJCET (Deny with a message) rest all type of incoming traffic from rest all sources
-A FORWARD -j REJECT --reject-with icmp-host-prohibited --> REJECT (Deny with a message) rest all type of forwarding traffic from rest all sources
-A OUTPUT -p icmp -m icmp --icmp-type 8 -j DROP --> DROP (Deny without a message) ping request sending from localhost
COMMIT --> Save and apply all the above rules
# Completed on Thu Apr 24 14:51:47 2014

Saturday, 19 April 2014

Required Repo's for CentOS 6.X

EPEL :

wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm

rpm -Uvh epel-release-6-8.noarch.rpm

RPMForge:

## RHEL/CentOS 6 32 Bit OS ##
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.i686.rpm

## RHEL/CentOS 6 64 Bit OS ##
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

RPM Fusion:

# rpm -Uvh http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
# rpm -Uvh http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm

REMI:

# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6.rpm