13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

172Chapter 6The IBM Developer Kit for <strong>Linux</strong>, Java 2 Technology Editi<strong>on</strong>Example 6.1 Attempt to hardlink between mounts$ ln example /boot/sampleln: creating hard link `/boot/sample' to `example': Invalid cross-device link$Example 6.2 Symlinking /etc/passwd$ ls -latotal 8drwxrwxr-x 2 mschwarz mschwarz 4096 Jul 8 15:30 .drwx------ 50 mschwarz mschwarz 4096 Jul 8 15:29 ..$ ln -sf /etc/passwd passwd$ ls -latotal 8drwxrwxr-x 2 mschwarz mschwarz 4096 Jul 8 15:31 .drwx------ 50 mschwarz mschwarz 4096 Jul 8 15:29 ..lrwxrwxrwx 1 mschwarz mschwarz 11 Jul 8 15:31 passwd -> /etc/passwd$ cat passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaem<strong>on</strong>:x:2:2:daem<strong>on</strong>:/sbin:/sbin/nologin...etc.What we did here works just like a hard link, but note the attributes<strong>on</strong> the file: The l indicates a symbolic link, and the permissi<strong>on</strong>s areread/write/execute for user, group, and other (or for “world” for short). However,these permissi<strong>on</strong>s apply to the link, not to the file. Just as with hard links,there is <strong>on</strong>ly <strong>on</strong>e set of permissi<strong>on</strong>s <strong>on</strong> the file, and these are <strong>on</strong> the file that ispointed to, not <strong>on</strong> the pointer.One interesting difference between symlinks and hard links is that symlinksdo not increment the link count <strong>on</strong> a file. If we remove /etc/password(a very bad idea, by the way), the symlink would be unaffected, but an attemptto open or read the symlink would not work, because it points at nothing thatexists. This is called a dangling symlink.Symlinks may refer to symlinks, and thus you need to be cautious to avoidcircular symlink chains. All the shells we have used <strong>on</strong> <strong>Linux</strong> report circularsymlinks as “too many levels of symbolic links,” which sounds like a processexceeding its stack limits but handling it gracefully.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!