In: Computer Science
Doing the work on Linux in Putty:
You are to create a hard link to one of your existing files on someone else's directory (or vice versa). In other words, you know that you can link a file within your own directories, but you can also have a link to one of your files on other areas of the unix system as long as you have permissions to write to that directory (in this case, your partner).
Create a subdirectory called temp where you can place this temporary link. Remember that you do not link a file to another file. You create a hard link to an existing file. So, user A has file1 that he/she wants to give access to user B. User B has to open certain directory permissions, for this to happen, then User A can create the link on user B directory (user A NEVER goes to user B directories typing cd), but if permissions are opened correctly all the commands will be done from user A directory without shell error messages such as “can not access..”.
We cannot get the ln part to work. How do you share the hard link with the other user???
Please find the answer for the given question.
Hard link:
Hard link is a copy of the selected file. Hence this accesses
the data available from the original file.
If the original selected file is removed or deleted, then the hard
link pointing to the original file will still have the data of the
source/original file.
Syntax for creating hard links:
ln [source filename] [destination link file name]
Note: LInk name can be absolete path also
Sample Output:
#following four commands are used to crate temporary
directory by another user and he/she has given full
permission
#so that the others users can create hard links with out "cd" to
their directory.
USERLOGO@linux-server$ mkdir TEMP
USERLOGO@linux-server$ ls -ld TEMP
drwxrwxr-x 2 USERLOGO USERLOGO 4096 Oct 17 13:02 TEMP
USERLOGO@linux-server$ chmod 777 TEMP
#following commands explains how we are creatning the hard links.
USER>echo "HI" >file1
USER>cat file1
HI
USER>
USER>ls -l file1
-rw-rw-r-- 1 jhon jhon 3 Oct 17 13:03 file1
USER>
USER>ln file1 /home/USERLOGO/TEMP/file1-hardlink
USER>cat /home/USERLOGO/TEMP/file1-hardlink
HI
USER>ls -l /home/USERLOGO/TEMP/file1-hardlink
-rw-rw-r-- 2 jhon jhon 3 Oct 17 13:03
/home/USERLOGO/TEMP/file1-hardlink
USER>
Screen Shot: