Archive for November, 2008

understanding ‘diff’ command

November 6, 2008

diff sample.old sample.new
5c5
< you agree to the terms

> you agree to the terms and conditions
7d6
< Six ounces chopped liver
21a22
> Note: The previous version of this recipe had a few errors!

The output is actually a description of how to transform the old file into the new one. Here, diff is telling you three things:

~ The 5c5 message says to replace line 5 of the old file with line 5 of the new file. Both the old and new text are displayed, separated by a line of three dashes. (The less-than (<) notation means “remove this line,” and the greater-than (>) sign means “add this line.”)

~ The 7d6 message says to delete line 7 from the old file, and the files will then be in sync, starting at line 6 of the new file. The text to be deleted is displayed on the next line.

~ The 21a22 message says to add a new line after line 21 of the old file. The text to be added is displayed on the final line of the output.

Advertisements

rsync copy

November 5, 2008

rsync -vaur playzone04:nagios-3.0.3.tar.gz –rsh=ssh –rsync-path=/usr/local/bin/rsync .

-v, –verbose               increase verbosity

-a, –archive               archive mode; same as -rlptgoD (no -H, -A)

-u, –update                skip files that are newer on the receiver

-r, –recursive             recurse into directories

–rsync-path=/<rsync path of remote host>

Some times you will find error like

ld.so.1: rsync: fatal: libgcc_s.so.1: open failed: No such file or directory

i.e. no libgcc found on /usr/local/lib and rsync always look for libgcc_s.so.1 on /usr/local/lib

Then simply make a soft link

ln -s /usr/sfw/lib/libgcc_s.so.1 /usr/local/lib/libgcc_s.so.1 [on Sun host only]

Creating user, db and granting permission on mysql

November 4, 2008

To create a user-
mysqladmin –user=root -p create cacti
or
mysql -u root -p
CREATE USER ‘user1’@’localhost’ IDENTIFIED BY ‘pass1’;
GRANT ALL ON *.* TO ‘user1’@’localhost’;
flush privileges;

To create database-
create database <name>;

To set required permission

mysql>grant all on blog.* to blogadm@localhost;
Query OK, 0 rows affected (0.06 sec)

mysql> GRANT USAGE ON blog.* to blogadm@localhost IDENTIFIED BY ‘passwd’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON blog.* to blogadm@”%”;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON blog.* to blogadm@”%” IDENTIFIED BY ‘passwd’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)