• Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between /dev/urandom & file:/dev/./urandom  RSS feed

 
premchand Singh
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have doubt in the signature of the two paths which is used as java secure file :

file:/dev/urandom
$
file:/dev/./urandom

can anybody please let me know what is the difference between them..

Thanks
Premchand
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a Unix champion, but I believe the first one is a path to the file, while the second one executes it (and gives you a secure random number).

Nope, there is no difference. The extra "./" just means "current directory", like it does in Windows.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like something platform‑specific which you would never see on a Windows® box.

Try putting those two into a Path object (or a java.io.File object) and call getXXX methods on them. Try for the path and the canonical path. I think you will find that the second turns into the first when you use the canonical path. What you have in the first is
  • 1: You are looking for a file on your own machine rather than elsewhere via http, ftp, etc.
  • 2: The / takes you to the very root of the file system.
  • 3: dev/ is one of the directories in the file system.
  • 4: It contains a file called urandom.
  • The difference in the second is that after dev, you are calling ./ Now . means current directory (I think it is the same on Windows®) so ./ means look in the same directory that you were in already. So you can remove the ./ and not change the meaning of the path. Or you can add ./ as often as you like (in the middle of the path String) without changing where you end up.
     
    Campbell Ritchie
    Marshal
    Posts: 55761
    163
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    They are both the same: look. Same output for both
    campbell@campbellsComputer:someDirectory$ file:/dev/urandom
    bash: file:/dev/urandom: No such file or directory
    campbell@campbellsComputer:someDirectory$ file:/dev/./urandom
    bash: file:/dev/./urandom: No such file or directory
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!