There are 2 types of link that you can create...hard links and soft, or symbolic links. Both are created using the ln command.
Hard links are created by the system creating an extra reference to a specific disk inode, so you have 2 or more filenames pointing at the same piece of disk. Once created, you can't tell which was the original file and which is the link. A file won't actually be deleted until all links to it are removed. When you run the "ls -l" command, the second column (normally 1s and 2s) is the number of links to the file. As hard links are created at disk level, you clearly can't have hard links crossing file systems.
A soft link is simply another file that contains an arbitrary string which would be the path to another file anywhere on the system. Note that it could also be an incorrect path to a non-existent file! Consider it similar to a Windoze desktop shortcut.
So back to your example, in your videos directory, you can run the command...
By default, the symbolic name will match the name of the target file so a target link name isn't necessary here. This will create a symbolic link to movie4 and allow you to access it directly in the videos directory as if it was really there. Obviously if you had a real movie5 in videos as well as another movie5 in /usb/videos, you'll have to give the link another name.
"rm movie4" in the videos directory will remove the link and NOT the target file, while the same command in the /usb/videos directory will remove the file and would leave the /videos/movie4 link pointing at a non-existent file.
d.the.duck has suggested using 'ln-F' ... this is for directory linking rather than files and I'm not sure will work as expected.
I want to make a symbolic link to a set of files in a particular directory if they exist. The number of files in the set is not known. The following script fails because it is ambigious.
if(-f dir1/*.a) then
ln -s dir1/*.a dir2/
endif
Can anyone help me?
Thanks a lot. (1 Reply)
Hi,
I have a quick question with regards to creating symbolic links. Would creating a symbolic link from one directory to a file in another cause any issues for users that are currently logged into the box. I don't believe it will unless they are using the file in question, but I would like... (2 Replies)
hi,
How do i create a tar file of a directory excluding the links in that particular directory and its sub-directories.
The below command doesnt work for me.
tar -cvf abc.tar /dir1 --exclude"^l" (1 Reply)
i'm trying to write a c code to copy a soft link over to a specified directory. Is it possible to do this without using symlink()?
if so, what can I use?
Thanks! (2 Replies)
Hi all,
I am working on a project where I need to access four random machines from a given subnet mask and sending files across the machines similar to peer to peer file systems. Now my question is. Given a subnet mask or If I obtain a random IP address of a machine from Subnet mask, how can I... (4 Replies)
Hello,
Greetings!
please help me produce the following solution. I need
to produce one big matrix file from several files in different levels.
If it helps, the index folder provides information on chromosome index and
the data folder provides information on values for chromosomes.
there... (8 Replies)
Hi,
I have all my pictures as *.JPG and *.CR2 in the following folder structure:
/media/a_2TB/pictures/year/year-month-day-hour/picture*.*
But sometimes I added a subdirectory -->
/media/a_2TB/pictures/year/year-month-day-hour/suba/picture*.*... (3 Replies)
Hello, im trying to create folders from text file and i get errors :(
#!/bin/bash
awk 'BEGIN { RS = "/" } ; { mkdir $1, mkdir $2, mkdir $3, mkdir $4, mkdir $5}' zodziai.txt
im new in linux stuff just trying to learn. The idea is i want to create new folders from words in text file. I... (4 Replies)
Hi I've been trying to find an answer to this question and was hoping someone would be able to help me.
I want to add a sub-folder to to an existing structure: for example
/toys/toy_1/new
/toys/toy_2/new
/toys/toy_3/new
There are humdreds of theses folders - what i want to do is add a... (2 Replies)