$ whatis ln

ln ln (1) - make links between files

Examples:

# ln --version

ln (GNU coreutils) 8.5 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Parker and David MacKenzie. In order to make a symbolic or physical link to a binary or file, I need to know the location of the binary/file. In this case, I am using nslookup as an example, so I type the command which to find the location of the nslookup binary.

# which nslookup

/usr/sbin/nslookup Now, I create a symbolic link file to nslookup and call this new created file as symlink-2-nslookup.

# ln -s /usr/sbin/nslookup symlink-2-nslookup

# file symlink-2-nslookup

symlink-2-nslookup: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped

# ln -P /usr/sbin/nslookup ln-P-2-nslookup

Now, I want to see the type of the files that I had created using the commands 'link' and 'ln' in previous examples.

# file *nslookup

link-2-nslookup: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped ln-P-2-nslookup: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped ln-s-2-nslookup: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped symlink-2-nslookup: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped Here, I want to get the i-node numbers of the files I had created using the commands 'link' and 'ln' in previous examples. As you can see the i-node number of the files created with the command 'link' and 'ln -P' are the same due to being physically linked, in oppose to the files that were created with 'ln -s' for symbolic or logical name which have different i-node number. As you can see from the output of the command below, the two symbolic or logical name files are kind of pointers that are pointing to the physical binary or file.

# ls -li *nslookup

55980 -r-xr-xr-x 3 root bin 81884 2010-11-05 08:02 link-2-nslookup 55980 -r-xr-xr-x 3 root bin 81884 2010-11-05 08:02 ln-P-2-nslookup 146254 lrwxrwxrwx 1 root root 18 2011-04-23 12:40 ln-s-2-nslookup -> /usr/sbin/nslookup 146253 lrwxrwxrwx 1 root root 18 2011-04-23 12:38 symlink-2-nslookup -> /usr/sbin/nslookup Now, we are using the some examples of the actually binary and the new created files. The output of the commands are the same in either case.

# ./nslookup ourunix.com

Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: ourunix.com Address: 173.51.166.200

# ./link-2-nslookup ourunix.com

Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: ourunix.com Address: 173.51.166.200

# ./ln-P-2-nslookup ourunix.com

Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: ourunix.com Address: 173.51.166.200

# ./ln-s-2-nslookup ourunix.com

Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: ourunix.com Address: 173.51.166.200

# ./symlink-2-nslookup ourunix.com

Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: ourunix.com Address: 173.51.166.200 Notice, the output of the of the 'ls -l and ls -L' commands below on the sybolic link file.

# ls -l ln-s-2-nslookup

link-2-nslookup ln-P-2-nslookup ln-s-2-nslookup symlink-2-nslookup

# ls -L ln-s-2-nslookup

ln-s-2-nslookup

Please click on " man ln. " to see the Manual Page for this command.


Previous Home Page Next


Contact us      |      About us      |      Term of use      |       Copyright © 2000-2023 MyWebUniversity.com ™