Discussion Locked

Linux commands

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
What is Grep command?

9 replies

by Former member

Grep command is to compare the string.

by nex6

grep, allows you to "look" into files and filesystems:

here is an example:

[root@localhost nex6]# grep fw3 input
grep: input: No such file or directory
[root@localhost nex6]# grep INPUT fw3
iptables -P INPUT DROP
iptables -A INPUT -i eth0 -m state --state NEW -p tcp --destination-port 22 -j ACCEPT
#iptables -A INPUT -i eth0 -m state --state NEW -p tcp --destination-port 515 -j ACCEPT
#iptables -A INPUT -i eth0 -m state --state NEW -p tcp --destination-port 135:139 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state INVALID -j LOG \
iptables -A INPUT -m state --state INVALID -j DROP
#iptables -A INPUT -i $INTERNET -p icmp \
#iptables -A INPUT -i $INTERNET -p tcp -d $IPADDR-j LOG
iptables -A INPUT -p tcp --dport 22 -j LOG
#iptables -A INPUT -i eth0 -j LOG
[root@localhost nex6]#

This is a grep of a sample iptables script is was playing with.

it works like this:
grep [string to match] file/filessystemHere is a thread with at ARS with lots of command examaples:
http://arstechnica.infopop.net/OpenTopic/page?q=Y&a=tpc&s=50009562&f=96509133&m=6020942225&p=1

-Nex6

by manish_rit21

Grep command is used to find any particular thing. You will Grep more useful when you use Pipe with this.

by gtkfreak

Last one in... Always try:
$ man grep

Will give you all info you want.

$ info grep
will also work.

This discussion is closed to new replies.