31 May 2015

info

  1. ln creates links between files

  2. ln option target linkname

    • ln creates a link to file target

    • with the name linkname

    • ln creates hard links by default

    • -s or --symbolic for symbolic links

demo

  1. create file and link

         # create a file `a`
         $ echo "hello" > a
    
         # create `hard link`
         # called `b` to `a`
         $ ln a b
    
         # create `soft link`
         # called `c` to `a`
         $ ln -s a c
    
  2. printing the contents

         $ cat a
         hello
    
         $ cat b
         hello
    
         $ cat c
         hello
    
  3. remove file a

         $ rm a
    
  4. printing the contents again

         $ cat a
         cat: a: No such file or directory
            
         $ cat b
         a
            
         $ cat c
         cat: c: No such file or directory
    


blog comments powered by Disqus