0

I accidentaly linked my root file system directories /bin and /sbin to /usr/bin and /usr/sbin instead of /mnt/bin and /mnt/sbin.

ln -sv /bin /usr/bin ln -sv /sbin /usr/sbin 

Then I wanted to revert it so I found on the internet that I could unlink them so I did:

unlink /bin unlink /sbin 

I didn't know what unlink does and now I see that it deleted my /bin and /sbin completely. Now no command works

ls -l zsh: command not found: sudo _user_host:1: command not found: who 

Is there a way to restore it and fix it? If I run a live CD and mount my partition and recreate the directories /bin/ /sbin and restore the symlinks to /usr/bin and /usr/sbin will that fix it?

1
  • You can still see what exists in a directory by issuing a builtin, ie echo *. From there, you can reset PATH or use a full path to execute commands such as ln. If those directories are gone however, you will probably need to reinstall or upgrade which should preserve all data and configs. Commented Nov 19, 2022 at 12:01

1 Answer 1

0

I managed to fix it. I have a GPARTED partition on my disk that I created a while ago to be able to quickly manage my partitions and it turned out to be useful this time. I booted into my gparted which offers a terminal, I mounted my root partition and copied everything from /usr/bin/, /usr/sbin/ and /usr/lib to / and that fixed everything. What caused my issue was that I was running some bash scripts which required an environment variable $LFS which wasn't set because I didn't source a file that included this env. This resulted on operating on my root file system so instead of symlinking my /mnt/lfs/bin I symlinked /bin to /bin/usr/bin. Lesson learned the hard way :D

2
  • Yes, you copied across, but did they have updates installed? Commented Nov 19, 2022 at 15:49
  • Why do you ask? Aren't they just what was before in /bin and /sbin? Commented Nov 19, 2022 at 15:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.