Thursday, November 23, 2006

grep command : Finds text within a file

The grep command searches for the pattern specified by the Pattern parameter and writes each matching line to standard output.
Examples

0. $ grep '12.00' /home/prabhat/backup/log.txt
This command basically shows how you can use grep to extract lines containing a particular string from a text file.
1. To use a pattern that contains some of the pattern-matching characters *, ^, ?, [, ], \(, \), \{, and \}, enter:
grep "^[a-zA-Z]" pgm.s
This displays every line in pgm.s whose first character is a letter.

2. To display all lines that do not match a pattern, enter:
grep -v "^#" pgm.s
This displays every line in pgm.s whose first character is not a # (pound sign).

3. To display all lines in the file1 file that match either the abc or xyz string, enter:
grep -E "abc|xyz" file1

4. To search for a $ (dollar sign) in the file named test2, enter:
grep \\$ test2
The \\ (double backslash) characters are necessary in order to force the shell to pass a \$ (single backslash, dollar sign) to the grep command. The \ (single backslash) character tells the grep command to treat the following character (in this example the $) as a literal character rather than an expression character. Use the fgrep command to avoid the necessity of using escape characters such as the backslash.

^ - match at the beginning of the line
$ - match at the end of the line

Some extra options for grep
-v
Reverses the normal behavior of the grep command - Instead of selecting lines, it rejects the lines that match the given criteria.
-c
It suppresses the normal output and only prints the total count of matching lines instead of the actual lines.
-i
Ignores the case of the text when matching the given pattern.
-w
Checks if the given pattern is a word by itself and not a part of another word. Thus if you search for 'bay' and the word 'baywatch' is present in a file, the particular line containing that word would not be returned in the result.
-l
Only gives the names of the files in which the given pattern was found.
-r
Checks for the given pattern , recursively within the directory that you specify after the -r option

know more
http://www.computerhope.com/unix/ugrep.htm
http://linux.about.com/od/commands/l/blcmdl1_grep.htm
http://www.lowfatlinux.com/linux-grep-manual.html

Wednesday, November 22, 2006

yum : Yellow dog Updater, Modified

automated software installation and update for linux
yum is software installation tool for Red hat linux and Fedora Linux. It is a complete software management system. yum is designed to use over network/internet. It does not use CDROM to install packages. If you are using fedora you don't have to install it, it is part of fedora itself.

In the case u don't have yum, then u can download yum from project home page http://linux.duke.edu/projects/yum/download.ptml
u can Install using.(it is avaliable in rmp)
# rpm -ivh yup*
U can Configure yum editing /etc/yum.conf
# emacs /etc/yum.conf
Append or edit code as follows:
[base]
name=Fedora Core $releasever - $basearch - Base
baseurl=http://apt.sw.be/fedora/$releasever/en/$basearch/dag
baseurl=http://mirrors.kernel.org/fedora/core/$releasever/$basearch/os
Install GPG signature key with rpm command:
# rpm --import http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
and other keys too (if any using above command)
Update your package list:
# yum check-update
Install a new package called test
# yum install test
To update packages
# yum update
To update a single package called test1
# yum update test1
To remove a package called test2
# yum remove test2
To list all packages
# yum list installed
You can search using grep command
# yum list installed | grep test1
Display information on a package called test
# yum info test
To display list of packages for which updates are available
# yum list updates
To clean all cahced packages:
# yum clean packages
To remove all cached packages and old headers:
# yum clean all
Force a fresh download of package
yum clean headers
yum clean oldheaders
To Know more visit :
http://www.die.net/doc/linux/man/man5/yum.conf.5.html http://www.linuxcommand.org/man_pages/yum8.html
http://www.linuxmanpages.com/man8/yum.8.php

Thursday, November 16, 2006

Did u know how many virtual web site's ?

Following command show how many virtual web site's running on ur server.

httpd -t -D DUMP_VHOSTS
or
apache2 -t -D DUMP_VHOSTS

Saturday, November 11, 2006

How to keep a computer from answering to ping?

it is possible to block pings entirely to your machine..

a simple
"echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all" will do the trick...

to turn it back on, simply
"echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all"

Optimizing the operating system (OS) for MySQL server

 Optimizing the operating system (OS) for MySQL server Optimizing the operating system (OS) for a MySQL server involves configuring various ...