You are not logged in.

#1 2018-12-06 11:39:50

felixdatboi
Member
Registered: 2018-11-01
Posts: 26

Accidently created symlinks that references themself

I tried to create symlinks to all my dotfiles. Create a new folder `~/Projects/dotfiles/` added symlinks into this. Then, after, i figured out that github dont track changes in symlinks i removed to folder.

Then I tried to edit my bashrc it said `Too many levels of symbolic link` And I saw that they somehow (after i removed my dotfiles folder) started to reference themself.

So when I do `ls` in my home folder they look like this: `.xinitrc -> /home/felix/.xinitrc` and I cant open them. I tried to remove the symlink with for one of my dotfiles by doing `rm /home/felix/.*` but that (of course) just deleted the file. Then I tried to unlink the file `unlink .bashrc` but that also deleted the file..

Is there anyway to save my files?

Offline

#2 2018-12-06 12:25:39

sincomil
Member
Registered: 2018-02-13
Posts: 106

Re: Accidently created symlinks that references themself

Generally, no. But it depends on filesystem in which you had the files.
Added: you can give a try for this utilities: extundelete, ext4magic If you have ExtN filesystem. For XFS  there if no official method for restoring files. btrfs has restore procedure

Last edited by sincomil (2018-12-06 12:43:41)

Offline

#3 2018-12-06 12:44:15

seth
Member
Registered: 2012-09-03
Posts: 50,923

Re: Accidently created symlinks that references themself

1st off: stop doing wild things.
"man unlink" would have told you that this actually removes files - it's not related to symlinks.

Next: "somehow started to reference themself" is not a thing, this does not happen magically. It is paramount to understand what you *actually* did. I'd ask you to look up your bash history, but that's probably gone.

Did you somehow™ upload the dotfiles somewhere? Because the files are now (by any provided evidence) gone.
If not: stop altering the filesystem. Do not mount the /home partition, do not write, add or delete files there. Avoid any kind of change. NOTICE: that almost every program you run will somehow write to your $HOME!

If need be, use a live system like grml and see https://wiki.archlinux.org/index.php/File_recovery

Offline

#4 2018-12-06 15:33:25

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Accidently created symlinks that references themself

felixdatboi wrote:

I tried to create symlinks to all my dotfiles. Create a new folder `~/Projects/dotfiles/` added symlinks into this. Then, after, i figured out that github dont track changes in symlinks i removed to folder.

Then I tried to edit my bashrc it said `Too many levels of symbolic link` And I saw that they somehow (after i removed my dotfiles folder) started to reference themself.

So when I do `ls` in my home folder they look like this: `.xinitrc -> /home/felix/.xinitrc` and I cant open them. I tried to remove the symlink with for one of my dotfiles by doing `rm /home/felix/.*` but that (of course) just deleted the file. Then I tried to unlink the file `unlink .bashrc` but that also deleted the file..

Is there anyway to save my files?

So you accidentally deleted the file and replaced it with a symlink. Oops. wink As other posts have said, you need to start the standard operating procedure for data loss and attempted recovery. This may not work. Unfortunately, it appears the cause of the problem is that you didn't have backups, therefore you cannot just use backups to restore...

...

For the future, since apparently symlinks to dotfiles are something causing you grief, you may want to consider my alternate approach. https://github.com/eli-schwartz/dotfiles.sh


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB