For the sake of simplicity, suppose the following situation, where folder is a symlink to new_folder:

├── folder -> new_folder/
├── new_folder
│   └── test.sh
└── exectest.sh

The contents of test.sh are:

echo 'test'

The contents of exectest.sh are:

echo 'executing test'

If I run ./exectest.sh, the output is as expected:

executing test

Now let's suppose I want to remove folder, so I'll do unlink folder. But if I run ./exectest.sh, it'll throw an error:

executing test
./exectest.sh: line 3: ./folder/test.sh: No such file or directory

So my question is: how to remove folder without breaking exectest.sh?

If that matters, something similar is happening with my user folder: when I bought this computer, the ~ directory was /home/user/. After a while, I decided to change it to /home/new_user/. As in that period I had installed some programs that depended on /home/user/, I created a symlink called /home/user/ pointing to /home/new_user/. Now I want to remove /home/user/ and keep only /home/new_user/, but it will break some files that still depend on it.

What to do in this situation? Thanks in advance.


There's no easy answer to this.

You're going to have to search through all the files that refer to /home/user (or folder) and hope that they're editable and can be changed to /home/new_user (or new_folder).

| improve this answer | |
  • What a pity... Do you think something like sed -i 's-/home/user-/home/new_user-g' /home/new_user/* could solve the problem? – Enzo May 4 at 15:10
  • It might. But it could also irretrievably corrupt non-text database files so beloved of subsystems like Gnome. – roaima May 4 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.