-1

I am new to Linx.

I have a file oops.c in /home/tuna/objects directory.

I wanted to create a symbolic link for above file in /home/tuna/myfolder .

I tried cd /home/tuna/myfolde $: ln -s /home/tuna/objects/oops.c oops.c

And when i open the link, its empty. I want to have the link same as original file .

Please help

4

3 回答 3

2

我会ls看看它是否正确链接到文件。

键入ls -l并查看目录中的文件列表/home/tuna/myfolder。您应该会看到如下内容:

lrwxrwxrwx 1 tuna None xx Sep 16 12:00 oops.c -> /home/tuna/objects/oops.c

如果您没有看到类似的内容,您可能需要使用完整路径重试。喜欢:

ln -s /home/tuna/objects/oops.c /home/tuna/myfolder/oops.c

于 2013-09-16T20:05:13.080 回答
1
ln -s /path/to/file /path/to/symlink

所以在你的情况下

ln -s /home/tuna/objects/oops.c /home/tuna/myfolde/oops.c
于 2013-09-16T19:56:33.007 回答
0

The simplest form of ln is this to create a symlink:

cd /home/tuna/myfolder
ln -s /home/tuna/objects/oops.c
cat oops.c     # This will print the file

What exactly do you mean when you say "when I look it is empty"?

An extract from ln's man page, just to clarify things:

   ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
   ln [OPTION]... TARGET                  (2nd form)
   ln [OPTION]... TARGET... DIRECTORY     (3rd form)
   ln [OPTION]... -t DIRECTORY TARGET...  (4th form)

Your original code is the 3rd form which tries to create a symlink to /home/tune/objects/oops.c in the folder oops.c. You should use the 2nd form which creates a symlink called oops.c in the current folder, pointing to home/tuna/objects/oops.c.

于 2013-09-16T19:58:18.923 回答