Monday, December 29, 2014

puzzle - quiz - average


its the puzzle time of quiz times of Newyork times of america:
            Company C sells a line of 25 products with an average retail price of $1200.
if none of these products sells for less than $420 and exactly 10 of the products
sell for less than $1000, what is the greatest possible selling price of the most expensive product?
a) $2600
b) $3900
c) $7800
d) $11800
e) $18200

Thursday, December 18, 2014

happy birthday to sekar !!!

Two three days back, near our home(to be precise the "rented home"), saw this S shaped leaf.. so nice… God is Great, isnt?!?! .. and incidentally, yesterday the December 17th was my bday.
few more steps, got the second photo.. 
for more on my photography, pls check my fb album, “>>>please check my fb album<<<"
(if u send a friend request or a like or a comment, that would be bday gift ;) ;) )
sorry for the photo clarity, taken with nexus 5.




Saturday, November 22, 2014

PEMDAS - Parentheses Exponents Multiplication Division Addition Subtraction

What is the order of operations?
In the United States we use an acronym called PEMDAS, which stands for Parentheses Exponents
Multiplication Division Addition Subtraction. That’s the order Python follows as well.

Tuesday, September 30, 2014

Perl CPAN - Perl Modules..

As of Oct 1st 2014...,... 
"The Comprehensive Perl Archive Network (CPAN) currently has 138,660 Perl modules in 30,455 distributions, written by 11,752 authors,mirrored on 253 servers.
The archive has been online since October 1995 and is constantly growing".

Lets learn how to use a basic perl module and how to do some testing on them...
lets check this, for the time being, ..
http://stackoverflow.com/questions/8783008/what-is-the-proper-way-to-test-perl-modules-during-development
 

keep laughing, keep learning...
"keep walking... johnny walker"

Wednesday, June 25, 2014

unix-linux grep challenge answers

Lets see first 2 questions answers:

1. use grep to count the number of lines in a file(wc -l).ok, little tricky. you should match for a newline character(\n). or, simply, we can match for everything between ^ (beginning of the line) and $(end of the line)
and count the number of matches (-c)

invent@sekar -  [/home/sekar/learning]
# cat grep-test-file1
hi123
hello111
invent@sekar -  [/home/sekar/learning]
# grep -c '^.*$' grep-test-file1
2
invent@sekar -  [/home/sekar/learning]

2. use grep to open a file like cat. ie, using grep, replicate the "cat filename" task (try both versions - grep and egrep)
simple. match for everything on the given file.
grep * filename --- will not work. single quote or double quote needed.

invent@sekar -  [/home/sekar/learning]
# grep '*' grep-test-file
invent@sekar -  [/home/sekar/learning]
# grep "*" grep-test-file
invent@sekar -  [/home/sekar/learning]
# grep -e * grep-test-file    (u know y this didnt work, right)
invent@sekar -  [/home/sekar/learning]
# grep -e "*" grep-test-file    ;# (egrep match for everything)
hi123
hello123 456
invent@sekar -  [/home/sekar/learning]
# grep ".*" grep-test-file    ;# (grep match for everything)
hi123
hello123 456
invent@sekar -  [/home/sekar/learning]

grep "." grep-test-file --- will it work? analyze and try this please..

Friday, June 6, 2014

Unix/Linux - grep quiz - challenges - questions


Unix / Linux - grep command quiz / questions
Level - basic and intermediate.

As i learnt on few sites, quiz / challenges are the best way of learning something new.
Answers are in link - http://shellandperl.blogspot.com/2014/06/unix-linux-grep-challenge-answers.html


1. Use grep to open a file like cat. ie, using grep, replicate "cat filename" task (try both versions - grep and egrep)
2. use grep to count the number of lines in a file(wc -l).
3. use grep to count the number of empty lines in a file
4. find out all capital words on a given file
5. find out all dollar values($50, $10, $1, etc) on a given file
6. find out all US cell numbers(123-456-7890, +1-123-456-7890) on a given file
7. use grep to count the number of words on a given file(wc -w).
8. grep only the full words
9. grep for ip addresses
10. take any command, for example wc, thru grep, read its man page and find out its AUTHOR 

Tuesday, June 3, 2014

Volkswagen Car Collections

i like to post my Volkswagen collection, then, as its a small car, for contrast reason, i thought to post a Limo and a truck as well...  
i remembered the line - "Big Man the Laltain, Small Man the Mombatti" from that novel.


 
Just for comparison, i included this truck here... 

 the yellow Cute yellow VW...


from my friend's home..

 another red cute:


Yellow beauty front view:


Thursday, May 15, 2014

Dodge SRT challenger

Spotted a dodge SRT Challenger and caught it...
have a great day, guys...





Tuesday, May 13, 2014

All about Linux hard links and soft links/symbolic links




1. how to create a hard link
# ln target-file1 hard-link-for-target-file1

2. you can not link two existing files. you only can create a hard link for an existing file to a new file.
# ln file1 file2
ln: creating hard link `file2' to `file1': File exists

3. when you change target file, its hard linked file also changes

4. when ls --color=auto, hardlink files appear green color:





5. how to find hard link files / to search for hardlinks:
find /path -links  3 -exec ls -ld {} \;  -print

files with less than 3 links
find /path -links -3 -exec ls -ld {} \;  -print

files with more than 3 links
find /path -links +3 -exec ls -ld {} \;  -print



6. when you copy a hard link target/hard link file, it just copies the current file. the copied new file will not be a hard link'ed file

7. hard link target and hard links will have the same inode number. to find inode of the files: ls -li

# ls -li
total 12
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 file1
229419 -rw-rw---- 1 root esm 0 May  2 23:26 file2
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link-for-file1
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link2-for-file1

8. when you remove a hard linked file, target is still valid. (just the hardlink count will reduce by 1)

9. hard link not allowed for directory

root@sandp - TEST - MLM [/home/sandp]
# ln hard-soft-links dir1
ln: `hard-soft-links': hard link not allowed for directory
root@sandp - TEST - MLM [/home/sandp]

10. hard link can not be created on two different file systems:

root@sandp - TEST - MLM [/]
# ln /tmp/test1 /home/HL-test1
ln: creating hard link `/home/HL-test1' to `/tmp/test1': Invalid cross-device link
root@sandp - TEST - MLM [/]

11. You can also use the find command to search for symbolic links using the -type l find expression:

# find /home -type l -exec ls -l {} \; -print

12. on hard links, you can rename a file. hard links will be still valid:


Soft links vs Hard links - from wiki


############################
Soft links - Symbolic Links
############################

1. create a softlink: ln -s targetfile SL-for-targetfile

root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln -s testfile softlink-for-testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]

2. rename a softlink file --- the target file remains unchanged. the softlink still works as expected.

3. rename a softlink target file --- the softlink will not work
(to find out this one, use "ls -H", if target is not available, it will print "?" on the file permissions)

4. create a softlink between directories
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln -s SL-dir1 SL-for-dir1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]

5. when long listing, the softlink for a directory will have "l" on the first letter. it will not have a "d", but its still a directory, its not a regular

file (ie, softlink for a directory is a also a "directory", not a "file")


5. ls -H and ls -l dereference

-L, --dereference
when showing file information for a symbolic link, show information for the file the link references rather than for the link itself

-H, --dereference-command-line
follow symbolic links listed on the command line

i am not sure of this -H option. but -L is useful only. if the target file is not available, it will print "question marks" (????) for the file permissions.


# ll softlink-for-testfile-renamed
lrwxrwxrwx 1 root esm    8 May  5 09:21 softlink-for-testfile-renamed -> testfile

# ls -H softlink-for-testfile-renamed
lrwxrwxrwx 1 root esm    8 May  5 09:21 softlink-for-testfile-renamed -> testfile


# ls -L softlink-for-testfile-renamed

?--------- ? ?    ?      ?            ? softlink-for-testfile-renamed


6. softlink to a hardlinked file?  (softlink to a hardlinked file is still a hardlinked file, not a softlink file)

7. how to find the softlinks
--------------------------------------
find /path -type l
find /path -type l -exec ls -l {} \; -print

8. who links to me? (from a given hard link file, how to find out what other files are hard-linked to this given file)

# find /home -samefile file1
# find /home -inum 229418


To find which files are hard links to a particular inode, you can use the find command and the -samefile option with a filename or the -inum option with an

inode number, as shown in Listing 11.
Listing 11. Finding hard links to the same file

To find which files link symbolically to a particular file, you can use the find command and the -lname option with a filename, as illustrated in Listing 12.

Links may use a relative or absolute path, so you probably want a leading asterisk in the name to find all matches.


Copying versus linking
--------------------------
Depending on what you want to accomplish, sometimes you will use links and sometimes it may be better to make a copy of a file. The major difference is that

links provide multiple names for a single file, while a copy creates two sets of identical data under two different names.
You would certainly use copies for backup and also for test purposes where you want to try out a new program without putting your operational data at risk.

You use links when you need an alias for a file (or directory), possibly to provide a more convenient or shorter path. In the next section, we'll look at

some other uses for links.
As you have seen, when you update a file, all the links to it see the update, which is not the case if you copy a file. You have also seen that symbolic

links can be broken but that subsequent write operations may create a new file. Use links with care.


the uses of softlinks:
----------------------------
1. Links, especially symbolic links, are frequently used in Linux system administration. Commands are often aliased so the user does not have to know a

version number for the current command, but can access other versions by longer names if necessary.
As shown in Listing 13, the gcc command is a symlink and there are three different names for it on my system.

ian@attic4:~$ which gcc
/usr/bin/gcc
ian@attic4:~$ ls -l /usr/bin/gcc
lrwxrwxrwx 1 root root 7 2009-12-28 23:17 /usr/bin/gcc -> gcc-4.4
ian@attic4:~$ find /usr/bin -lname "*gcc-4.4"
/usr/bin/x86_64-linux-gnu-gcc-4.4
/usr/bin/gcc
/usr/bin/x86_64-linux-gnu-gcc


Above commands executions listed here:

1. create a hard link
--------------------------
2. you can not link two existing files. you only can create a hard link for an existing file to a new file.
--------------------------------------------------------------------------------------------------------------

root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# touch file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# touch file2
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 0
-rw-rw---- 1 root esm 0 May  2 23:26 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln file1 file2
ln: creating hard link `file2' to `file1': File exists



root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 0
-rw-rw---- 1 root esm 0 May  2 23:26 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln file1 hard-link-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 0
-rw-rw---- 2 root esm 0 May  2 23:26 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rw-rw---- 2 root esm 0 May  2 23:26 hard-link-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln file1 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 0
-rw-rw---- 3 root esm 0 May  2 23:26 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rw-rw---- 3 root esm 0 May  2 23:26 hard-link-for-file1
-rw-rw---- 3 root esm 0 May  2 23:26 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# echo hi > file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 12
-rw-rw---- 3 root esm 3 May  2 23:28 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rw-rw---- 3 root esm 3 May  2 23:28 hard-link-for-file1
-rw-rw---- 3 root esm 3 May  2 23:28 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat hard-link-for-file1
hi
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]

3. when you change target file, its hard linked file also changes:
--------------------------------------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# chmod 777 hard-link-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 12
-rwxrwxrwx 3 root esm 3 May  2 23:28 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link-for-file1
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


4. when ls --color=auto, hardlink files appear green color:
--------------------------------------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ls --color=auto
file1  file2  hard-link-for-file1  hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]

5. to find hard links / to search for hardlinks:
--------------------------------------------------------------------
find . -links  3 -exec ls -l {} \;  -print


these two forms are not working as expected. `man find` does not say anything about this. looks like this feature is not available on find.
files with less than 3 links
find . -links  -3 -print

files with more than 3 links
find . -links  +3 -print

find . -links  +3 -exec ls -l {} \;  -print

find /home -links +9 ---actully listing directories as well..




root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find . -links +2 -exec ls -l {} \; -print
-rwxrwxrwx 3 root esm 3 May  2 23:28 ./hard-link2-for-file1
./hard-link2-for-file1
-rwxrwxrwx 3 root esm 3 May  2 23:28 ./file1
./file1
-rwxrwxrwx 3 root esm 3 May  2 23:28 ./hard-link-for-file1
./hard-link-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find . -links 2 -exec ls -l {} \; -print
total 12
-rwxrwxrwx 3 root esm 3 May  2 23:28 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link-for-file1
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link2-for-file1
.
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find . -links -2 -exec ls -l {} \; -print
-rw-rw---- 1 root esm 0 May  2 23:26 ./file2
./file2
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


6. when you copy a hard link target/hard link file, it just copies the current file. the copied new file will not be a hard link'ed file
----------------------------------------------------------------------------------------------------------------------------------------

root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cp hard-link-for-file1 hard-link-for-file1-new
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 16
-rwxrwxrwx 3 root esm 3 May  2 23:28 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link-for-file1
-rwxrwx--- 1 root esm 3 May  2 23:53 hard-link-for-file1-new
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cp file1 cp-test
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwx--- 1 root esm 3 May  2 23:53 cp-test
-rwxrwxrwx 3 root esm 3 May  2 23:28 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link-for-file1
-rwxrwx--- 1 root esm 3 May  2 23:53 hard-link-for-file1-new
-rwxrwxrwx 3 root esm 3 May  2 23:28 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat cp-test
hi
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat hard-link-for-file1-new
hi
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
#
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# echo hello >> file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwx--- 1 root esm 3 May  2 23:53 cp-test
-rwxrwxrwx 3 root esm 9 May  2 23:54 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link-for-file1
-rwxrwx--- 1 root esm 3 May  2 23:53 hard-link-for-file1-new
-rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat cp-test
hi
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat hard-link-for-file1-new
hi
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]

7. inode of the hard linked files:
-------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ls -li
total 12
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 file1
229419 -rw-rw---- 1 root esm 0 May  2 23:26 file2
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link-for-file1
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
#

8. when you remove a hard linked file, target is still valid:
----------------------------------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ls -li
total 12
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 file1
229419 -rw-rw---- 1 root esm 0 May  2 23:26 file2
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link-for-file1
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# rm hard-link-for-file1
rm: remove regular file `hard-link-for-file1'? y
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 8
-rwxrwxrwx 2 root esm 9 May  2 23:54 file1
-rw-rw---- 1 root esm 0 May  2 23:26 file2
-rwxrwxrwx 2 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ls -li
total 8
229418 -rwxrwxrwx 2 root esm 9 May  2 23:54 file1
229419 -rw-rw---- 1 root esm 0 May  2 23:26 file2
229418 -rwxrwxrwx 2 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# rm file1
rm: remove regular file `file1'? y
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ls -li
total 4
229419 -rw-rw---- 1 root esm 0 May  2 23:26 file2
229418 -rwxrwxrwx 1 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat hard-link2-for-file1
hi
hello
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
#


9. hard link not allowed for directory
---------------------------------------


root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll -i
total 12
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 HL-file1
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 file1
229419 -rw-rw---- 1 root esm 0 May  2 23:26 file2
229418 -rwxrwxrwx 3 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cd ..
root@sandp - TEST - MLM [/home/sandp]
# ll
total 4
drwxrws--- 2 root esm 4096 May  3 00:00 hard-soft-links
root@sandp - TEST - MLM [/home/sandp]
# ln hard-soft-links dir1
ln: `hard-soft-links': hard link not allowed for directory
root@sandp - TEST - MLM [/home/sandp]



10. Invalid cross-device link
hard link can not be created on two different file systems:
----------------------------------------------------------------

root@sandp - TEST - MLM [/]
# touch /tmp/test1
root@sandp - TEST - MLM [/]
# ln /tmp/test1 /home/HL-test1
ln: creating hard link `/home/HL-test1' to `/tmp/test1': Invalid cross-device link
root@sandp - TEST - MLM [/]




11. You can also use the find command to search for symbolic links using the -type l find expression:
---------------------------------------------------------------------------------------------------------------------------

# find /home -type l -exec ls -l {} \; -print
lrwxrwxrwx 1 root esm 8 May  5 09:21 /home/esm/09119364/hard-soft-links/softlink-for-testfile-renamed -> testfile
/home/esm/09119364/hard-soft-links/softlink-for-testfile-renamed
lrwxrwxrwx 2 root esm 16 May  5 09:32 /home/esm/09119364/hard-soft-links/HL-file1-renamed-softlink-HL -> HL-file1-renamed
/home/esm/09119364/hard-soft-links/HL-file1-renamed-softlink-HL
lrwxrwxrwx 2 root esm 16 May  5 09:32 /home/esm/09119364/hard-soft-links/HL-file1-renamed-softlink -> HL-file1-renamed
/home/esm/09119364/hard-soft-links/HL-file1-renamed-softlink
lrwxrwxrwx 1 root esm 5 May  5 09:20 /home/esm/09119364/hard-soft-links/softlink-for-file1 -> file1
/home/esm/09119364/hard-soft-links/softlink-for-file1
lrwxrwxrwx 1 root esm 7 May  5 09:24 /home/esm/09119364/hard-soft-links/SL-for-dir1 -> SL-dir1
/home/esm/09119364/hard-soft-links/SL-for-dir1




12. on hard links, you can rename a file. hard links will be still valid:
-----------------------------------------------------------------------

root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 16
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# mv HL-file1 HL-file1-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 16
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ls -li
total 16
229418 -rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
229418 -rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
229418 -rwxrwxrwx 4 root esm 9 May  2 23:54 file1
229418 -rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat HL-file1-renamed
hi
hello
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]



1. create a softlink
-------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# touch testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# echo hello >> testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm 5 May  5 09:20 softlink-for-file1 -> file1
-rw-rw---- 1 root esm 6 May  5 09:21 testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln -s testfile softlink-for-testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm 5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm 8 May  5 09:21 softlink-for-testfile -> testfile
-rw-rw---- 1 root esm 6 May  5 09:21 testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


2. rename a softlink file
----------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm 5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm 8 May  5 09:21 softlink-for-testfile -> testfile
-rw-rw---- 1 root esm 6 May  5 09:21 testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# mv softlink-for-testfile softlink-for-testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm 5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm 8 May  5 09:21 softlink-for-testfile-renamed -> testfile
-rw-rw---- 1 root esm 6 May  5 09:21 testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]



3. rename a softlink target file
--------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# mv testfile testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 20
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm 9 May  2 23:54 HL-file1-test
-rwxrwxrwx 4 root esm 9 May  2 23:54 file1
-rwxrwxrwx 4 root esm 9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm 5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm 8 May  5 09:21 softlink-for-testfile-renamed -> testfile
-rw-rw---- 1 root esm 6 May  5 09:21 testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# mv testfile-renamed testfile
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat softlink-for-testfile-renamed
hello
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# mv testfile testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat softlink-for-testfile-renamed
cat: softlink-for-testfile-renamed: No such file or directory
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


4. create a softlink between directories(when ll, will it have l or d as the first letter?)
-------------------------------------------------------------------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln -s SL-dir1 SL-for-dir1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 24
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-test
drwxrws--- 2 root esm 4096 May  5 09:24 SL-dir1
lrwxrwxrwx 1 root esm    7 May  5 09:24 SL-for-dir1 -> SL-dir1
-rwxrwxrwx 4 root esm    9 May  2 23:54 file1
-rwxrwxrwx 4 root esm    9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm    5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm    8 May  5 09:21 softlink-for-testfile-renamed -> testfile
-rw-rw---- 1 root esm    6 May  5 09:21 testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cd SL-dir1/
root@sandp - TEST - MLM [/home/sandp/hard-soft-links/SL-dir1]
# touch hi
root@sandp - TEST - MLM [/home/sandp/hard-soft-links/SL-dir1]
# cd -
/home/sandp/hard-soft-links
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll SL-for-dir1
lrwxrwxrwx 1 root esm 7 May  5 09:24 SL-for-dir1 -> SL-dir1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cd SL-for-dir1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links/SL-for-dir1]
# cd ..
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# cat SL-for-dir1
cat: SL-for-dir1: Is a directory
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


5. ls -H and ls -l dereference
-------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll -H
total 24
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed
lrwxrwxrwx 2 root esm   16 May  5 09:32 HL-file1-renamed-softlink -> HL-file1-renamed
lrwxrwxrwx 2 root esm   16 May  5 09:32 HL-file1-renamed-softlink-HL -> HL-file1-renamed
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-test
drwxrws--- 2 root esm 4096 May  5 09:25 SL-dir1
lrwxrwxrwx 1 root esm    7 May  5 09:24 SL-for-dir1 -> SL-dir1
-rwxrwxrwx 4 root esm    9 May  2 23:54 file1
-rwxrwxrwx 4 root esm    9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm    5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm    8 May  5 09:21 softlink-for-testfile-renamed -> testfile
-rw-rw---- 1 root esm    6 May  5 09:21 testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll -L
total 40
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed-softlink
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed-softlink-HL
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-test
drwxrws--- 2 root esm 4096 May  5 09:25 SL-dir1
drwxrws--- 2 root esm 4096 May  5 09:25 SL-for-dir1
-rwxrwxrwx 4 root esm    9 May  2 23:54 file1
-rwxrwxrwx 4 root esm    9 May  2 23:54 hard-link2-for-file1
-rwxrwxrwx 4 root esm    9 May  2 23:54 softlink-for-file1
?--------- ? ?    ?      ?            ? softlink-for-testfile-renamed
-rw-rw---- 1 root esm    6 May  5 09:21 testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 24
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed
lrwxrwxrwx 2 root esm   16 May  5 09:32 HL-file1-renamed-softlink -> HL-file1-renamed
lrwxrwxrwx 2 root esm   16 May  5 09:32 HL-file1-renamed-softlink-HL -> HL-file1-renamed
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-test
drwxrws--- 2 root esm 4096 May  5 09:25 SL-dir1
lrwxrwxrwx 1 root esm    7 May  5 09:24 SL-for-dir1 -> SL-dir1
-rwxrwxrwx 4 root esm    9 May  2 23:54 file1
-rwxrwxrwx 4 root esm    9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm    5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm    8 May  5 09:21 softlink-for-testfile-renamed -> testfile
-rw-rw---- 1 root esm    6 May  5 09:21 testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]



6. softlink to a hardlinked file?  (softlink to a hardlinked file is still a hardlinked file, not a softlink file)
-------------------------------------------------------------------------------------------------------------------

root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln -s HL-file1-renamed HL-file1-renamed-softlink
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 24
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed
lrwxrwxrwx 1 root esm   16 May  5 09:32 HL-file1-renamed-softlink -> HL-file1-renamed
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-test
drwxrws--- 2 root esm 4096 May  5 09:25 SL-dir1
lrwxrwxrwx 1 root esm    7 May  5 09:24 SL-for-dir1 -> SL-dir1
-rwxrwxrwx 4 root esm    9 May  2 23:54 file1
-rwxrwxrwx 4 root esm    9 May  2 23:54 hard-link2-for-file1
lrwxrwxrwx 1 root esm    5 May  5 09:20 softlink-for-file1 -> file1
lrwxrwxrwx 1 root esm    8 May  5 09:21 softlink-for-testfile-renamed -> testfile
-rw-rw---- 1 root esm    6 May  5 09:21 testfile-renamed
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ln HL-file1-renamed-softlink HL-file1-renamed-softlink-HL
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# ll
total 24
-rwxrwxrwx 4 root esm    9 May  2 23:54 HL-file1-renamed
lrwxrwxrwx 2 root esm   16 May  5 09:32 HL-file1-renamed-softlink -> HL-file1-renamed
lrwxrwxrwx 2 root esm   16 May  5 09:32 HL-file1-renamed-softlink-HL -> HL-file1-renamed


7. using find to locate softlinks
--------------------------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find /home/sandp/ -type l
/home/sandp/hard-soft-links/softlink-for-testfile-renamed
/home/sandp/hard-soft-links/softlink-for-file1
/home/sandp/hard-soft-links/SL-for-dir1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find /home/sandp/ -type l -exec ls -l {} \; -print
lrwxrwxrwx 1 root esm 8 May  5 09:21 /home/sandp/hard-soft-links/softlink-for-testfile-renamed -> testfile
/home/sandp/hard-soft-links/softlink-for-testfile-renamed
lrwxrwxrwx 1 root esm 5 May  5 09:20 /home/sandp/hard-soft-links/softlink-for-file1 -> file1
/home/sandp/hard-soft-links/softlink-for-file1
lrwxrwxrwx 1 root esm 7 May  5 09:24 /home/sandp/hard-soft-links/SL-for-dir1 -> SL-dir1
/home/sandp/hard-soft-links/SL-for-dir1
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


8. who links to me?
-----------------------
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find /home -samefile file1
/home/sandp/hard-soft-links/hard-link2-for-file1
/home/sandp/hard-soft-links/file1
/home/sandp/hard-soft-links/HL-file1-renamed
/home/sandp/hard-soft-links/HL-file1-test
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]


root@sandp - TEST - MLM [/home/sandp/hard-soft-links]
# find /home -inum 229418
/home/oracle/PerlLib/Mail/.svn
/home/sandp/hard-soft-links/hard-link2-for-file1
/home/sandp/hard-soft-links/file1
/home/sandp/hard-soft-links/HL-file1-renamed
/home/sandp/hard-soft-links/HL-file1-test
root@sandp - TEST - MLM [/home/sandp/hard-soft-links]




To find which files are hard links to a particular inode, you can use the find command and the -samefile option with a filename or the -inum option with an

inode number, as shown in Listing 11.
Listing 11. Finding hard links to the same file

To find which files link symbolically to a particular file, you can use the find command and the -lname option with a filename, as illustrated in Listing 12.

Links may use a relative or absolute path, so you probably want a leading asterisk in the name to find all matches.


ian@attic4:~$ find lpi104-6 -samefile lpi104-6/file1
lpi104-6/subdir/file3sub
lpi104-6/file3
lpi104-6/file1
ian@attic4:~$ ls -i lpi104-6/file1
1680103 lpi104-6/file1
ian@attic4:~$ find lpi104-6 -inum 1680103
lpi104-6/subdir/file3sub
lpi104-6/file3
lpi104-6/file1



Copying versus linking
--------------------------
Depending on what you want to accomplish, sometimes you will use links and sometimes it may be better to make a copy of a file. The major difference is that

links provide multiple names for a single file, while a copy creates two sets of identical data under two different names.
You would certainly use copies for backup and also for test purposes where you want to try out a new program without putting your operational data at risk.

You use links when you need an alias for a file (or directory), possibly to provide a more convenient or shorter path. In the next section, we'll look at

some other uses for links.
As you have seen, when you update a file, all the links to it see the update, which is not the case if you copy a file. You have also seen that symbolic

links can be broken but that subsequent write operations may create a new file. Use links with care.



the uses of softlinks:
----------------------------
1. Links, especially symbolic links, are frequently used in Linux system administration. Commands are often aliased so the user does not have to know a

version number for the current command, but can access other versions by longer names if necessary.
As shown in Listing 13, the gcc command is a symlink and there are three different names for it on my system.

ian@attic4:~$ which gcc
/usr/bin/gcc
ian@attic4:~$ ls -l /usr/bin/gcc
lrwxrwxrwx 1 root root 7 2009-12-28 23:17 /usr/bin/gcc -> gcc-4.4
ian@attic4:~$ find /usr/bin -lname "*gcc-4.4"
/usr/bin/x86_64-linux-gnu-gcc-4.4
/usr/bin/gcc
/usr/bin/x86_64-linux-gnu-gcc


happy mothers day

கொஞ்சம் late ஆகிடுச்சு.. மன்னிச்சுக்குங்க..
Happy Mothers day...




Wednesday, April 23, 2014

the fountainhead novel - photos..

do you know the fountainhead novel?!?! if not, please check this wiki - http://en.wikipedia.org/wiki/The_Fountainhead
here are some photos i have taken that relating to this great novel. one more photo-story related to our Arundhati Roy's God of small things is on the way...

the fountainhead, in simple terms, it means a water jet. 


the whole novel is about buildings, architecture and much more actually.


on the climax, hero will be standing on top of the building.  and the novel's closing quotes are:

The line of the ocean cut the sky. The ocean mounted as the city descended. She
passed the pinnacles of bank buildings. She passed the crowns of courthouses.
She rose above the spires of churches.

Then there was only the ocean and the sky and the figure of Howard Roark.


Tuesday, April 22, 2014

Some people never noticed him at all

         Over time he had acquired the ability to blend into the background of wherever he was—into bookshelves, gardens, curtains, doorways, streets—to appear inanimate, almost invisible to the untrained eye. 
         It usually took strangers a while to notice him even when they were in the same room with him. It took them even longer to notice that he never spoke. Some never noticed at all. Estha occupied very little space in the world.