After creating a link to a folder, folders' content is empty

Created a Link with ln -s Programms/ Programms_Link, now all of my programs are gone ?

Edit : The filesystem on which the programs resided is an NTFS partition.

Are gone from where?

Are gone from where
=> the folder that has received a link, in which (the folder) they (the files (the programs)) have resided in.

Creating a link to folder made the folder go from a couple gigabytes to a couple of kilobytes

Something else happened. I use a lot of folder links and that never happened to me:

[lcoimbra@dg-lcoimbra ~]$ ls Programs/
JMathEdit
[lcoimbra@dg-lcoimbra ~]$ du -h Programs/ 
3,6M    Programs/JMathEdit/app/fonts
129K    Programs/JMathEdit/app/samples
3,7M    Programs/JMathEdit/app
6,0K    Programs/JMathEdit/runtime/conf/security/policy/limited
4,5K    Programs/JMathEdit/runtime/conf/security/policy/unlimited
17K     Programs/JMathEdit/runtime/conf/security/policy
63K     Programs/JMathEdit/runtime/conf/security
76K     Programs/JMathEdit/runtime/conf
5,5K    Programs/JMathEdit/runtime/include/linux
201K    Programs/JMathEdit/runtime/include
37K     Programs/JMathEdit/runtime/legal/java.base
3,5K    Programs/JMathEdit/runtime/legal/java.datatransfer
35K     Programs/JMathEdit/runtime/legal/java.desktop
3,5K    Programs/JMathEdit/runtime/legal/java.prefs
56K     Programs/JMathEdit/runtime/legal/java.xml
3,5K    Programs/JMathEdit/runtime/legal/jdk.httpserver
142K    Programs/JMathEdit/runtime/legal
2,0M    Programs/JMathEdit/runtime/lib/fonts
76K     Programs/JMathEdit/runtime/lib/jli
546K    Programs/JMathEdit/runtime/lib/oblique-fonts
257K    Programs/JMathEdit/runtime/lib/security
21M     Programs/JMathEdit/runtime/lib/server
90M     Programs/JMathEdit/runtime/lib
90M     Programs/JMathEdit/runtime
95M     Programs/JMathEdit
95M     Programs/
[lcoimbra@dg-lcoimbra ~]$ ln -s Programs/ Programs_Link
[lcoimbra@dg-lcoimbra ~]$ du -h Programs/
3,6M    Programs/JMathEdit/app/fonts
129K    Programs/JMathEdit/app/samples
3,7M    Programs/JMathEdit/app
6,0K    Programs/JMathEdit/runtime/conf/security/policy/limited
4,5K    Programs/JMathEdit/runtime/conf/security/policy/unlimited
17K     Programs/JMathEdit/runtime/conf/security/policy
63K     Programs/JMathEdit/runtime/conf/security
76K     Programs/JMathEdit/runtime/conf
5,5K    Programs/JMathEdit/runtime/include/linux
201K    Programs/JMathEdit/runtime/include
37K     Programs/JMathEdit/runtime/legal/java.base
3,5K    Programs/JMathEdit/runtime/legal/java.datatransfer
35K     Programs/JMathEdit/runtime/legal/java.desktop
3,5K    Programs/JMathEdit/runtime/legal/java.prefs
56K     Programs/JMathEdit/runtime/legal/java.xml
3,5K    Programs/JMathEdit/runtime/legal/jdk.httpserver
142K    Programs/JMathEdit/runtime/legal
2,0M    Programs/JMathEdit/runtime/lib/fonts
76K     Programs/JMathEdit/runtime/lib/jli
546K    Programs/JMathEdit/runtime/lib/oblique-fonts
257K    Programs/JMathEdit/runtime/lib/security
21M     Programs/JMathEdit/runtime/lib/server
90M     Programs/JMathEdit/runtime/lib
90M     Programs/JMathEdit/runtime
95M     Programs/JMathEdit
95M     Programs/
[lcoimbra@dg-lcoimbra ~]$ du -h Programs_Link
0       Programs_Link
[lcoimbra@dg-lcoimbra ~]$ ls Programs_Link/
JMathEdit
[lcoimbra@dg-lcoimbra ~]$ rm Programs_Link
[lcoimbra@dg-lcoimbra ~]$ ls Programs
JMathEdit

As you can see, it’s perfectly safe.

I’m not sure you can use Linux links in a NTFS partition. Although there are links in Windows, they work differently. The filesystem needs to support it. I suggest you use a Windows recovery software (in Windows) to try to recover the lost data.

I’ve made lots of links (in ntfs and ext4) as well, this is the first time breaking.

So there wouldn’t be a way to recover the things from linux?

What recovery tools would you recommend ?
Never needed to use any recovery software because I usually have good backups

On a NTFS partition I’m not sure.

Then you must have done something different. You can create a directory, put some content in it and test again to see what happens.

man ln

Mount your NTFS partition in a permanent location e.g. /data/windows

I not have tried to make a link to a folder on a nfts formatted partition but I assume the it will work.

While in your home folder execute

ln -sf /data/windows/path/to/linked/folder ~/Programms_Link

My shared drive is mounted with an fstab config :slight_smile:

To be honest I’m not sure what the command should accomplish ?

I don’t have difficulties creating links, I have difficulty dealing with freak occurrences like creating a link and then seeing all of ones data removed …

It doesn’t seam like it would restore the contents of a “wiped” directory

If you have a dual boot system, be aware that fast boot should be disable and you never should hibernate an OS and boot a different one to use the same partition. You will loose data if you do that.

Creating a link does not ever remove files - at least not that I know of - or have experienced.

But I will play with the concept …


I couldn’t make data disappear - but I also don’t know the circumstance - only from your description.

Steps I did:

  1. Create a exfat formatted USB
  2. Create a mount point /data/usb
  3. Mount the USB device to the mount point
    mount /dev/sdx1 /data/usb
  4. Create a folder tree
    mkdir /data/usb/test/if/data/dissappear
  5. Create a test file text.txt
  6. Attach a second USB and mount it to the a part of the tree
    mount /dev/sdy1 /data/usb/test
  7. create a new file /data/usb/test/test.txt
  8. try umount the first usb
    umount /dev/sdx1
    /data/usb: target busy
  9. umount /dev/sdy1
  10. check the path /data/usb/
    which still contains the previously hidden files

So I think you somehow has hidden the content much the same way I could hide the first usb when mounting the second.

I really don’t think you data is gone - puff - what I suggested is that a link can be created different ways as described in

$ man ln

...
       ln [OPTION]... [-T] TARGET LINK_NAME
       ln [OPTION]... TARGET
       ln [OPTION]... TARGET... DIRECTORY
       ln [OPTION]... -t DIRECTORY TARGET...
...

And you depending on the chosen command it has opposite effects of what you might have been expecting.

Yeah, as others had said, creating a link can not remove any files. The soft link creation process doesn’t even bother with the destination. You can create a soft link to a non-existent file/folder if you want. It’s not gonna even check it. So no, creating a link didn’t remove any files.

What else did you do?

Also, You have to be careful with mounts. As @linux-aarhus explained, they can hide some folders from view.