Score:0

No command executes when i deleted /lib64

au flag

I executed command rm -rf * when i was in lib64 or a directory inside it.

(Through comments/answers problem is that i deleted ld-linux-x86-64.so.2 and i don't have a temporary one inside /var/lib64)

(I have busybox )

Then I can't execute most of bash commands like ls,bash. When i try to execute them i see:

bash: /usr/bin/bash: No such file or directory

or

bash: /usr/bin/ls: No such file or directory

But a number of commands work properly like echo, cd

And a number of commands work but not properly like which that show the below error:

bash: /usr/bin/which: /bin/sh: bad interpreter: No such file or directory

When I go to /usr/bin through cd and then execute command cd $file it throw an error. for example, when i execute cd /usr/bin/ls it show me:

bash: cd: /usr/bin/ls: Not a directory

or

bash: cd: /usr/bin/bash: Not a directory

when i executed 'cd /usr/bin/bash'

and when i open the terminal i show the below message:

There was an error creating the child process for this terminal
Failed to execute child process “/bin/bash” (No such file or directory)

(With two option: Preferences, Relaunch)

My $PATH is /home/$me/.sdkman/candidates/springboot/current/bin:/home/$me/.cargo/bin:/home/$me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/grade/gradle-7.0.2/bin:/opt/apache-maven-3.8.1/bin:/home/$me/v8/depot_tools:/home/$me/.config/composer/vendor/bin I can use browser, or/and programs previously launched. But i can't launch them again.

I have one open terminal tab with a number of commands previously mentioned and a browser and a document reader. They work but they can't be launched again.

What is can't understand is the below error:

bash: /usr/bin/which: /bin/sh: bad interpreter: No such file or directory
guiverc avatar
cn flag
You've provided no OS & release details; but you'll need to restore that directory from your backups. If you delete a file that is already open; the existing running program can still read the contents (as inodes are not freed until nothing is using them - Ubuntu or GNU/Linux is a multi-user OS), but programs that need those libraries won't have them available as they were deleted, thus cannot execute. On reboot (or logout you'll see more effects) you'll see the full effect of your command. You could also re-install if you don't have backups.
muru avatar
us flag
You probably deleted `ld-linux.so`, which is needed for any dynamically linked executable to run.
Someone avatar
my flag
@muru don't you think [this question](https://unix.stackexchange.com/q/123353/495805)[And this answer](https://unix.stackexchange.com/a/123358/495805) solves this issue
PooiaFerdowsi avatar
au flag
@muru @algnis exactly I deleted that file. but no temporary ld-linux file is in `/var/lib64` directory. better: my `var` directory has not `lib64` directory inside.
bac0n avatar
cn flag
`/usr/bin/busybox ash` (you need to supply full path) should give you a working prompt. now, you should be able to re-create your missing link `ln -sf /lib/x86_64-linux-gnu/ld-2.33.so ld-linux-x86-64.so.2` pay attention to the ld-linux version.
bac0n avatar
cn flag
you can do the same from the grub menu, `e` edit any of the menu entries, append `break` to the *linux* line and *ctrl+x*, this should bring a `(initramfs)` prompt, you can then mount your root partition, something like `mount /dev/sda1 /root`, `cd /root/lib64`, this time you need to use a relative path `ln -sf ../lib/x86_64-linux-gnu/ld-2.33.so ld-linux-x86-64.so.2`
Score:3
cn flag

/usr/bin/which is a shellscript:

~$ cat /usr/bin/which
#! /bin/sh
set -ef

if test -n "$KSH_VERSION"; then
        puts() {
                print -r -- "$*"
        }
else
        puts() {
                printf '%s\n' "$*"
        }
fi
...
...
...

This are just the first lines of the script, it is much longer. But we just need to take a look at the very first line which is

#! /bin/sh

/bin is symlinked to /usr/bin, so /bin/sh points to /usr/bin/sh.

Seems you deleted essential systemfiles, that's why commands not work for you. cd and echo are not commands but shell-builtins, that's why they still work.

We can't tell you which files you removed since we don't know in which directory you issued the rm -rf *-command. Maybe it is possible to copy the files from a live-session and get the system back to work but you'll have to find out yourself which files are missing. Otherwise reinstall.

Hint: On my system I have only a single file in /lib64:

~$ ~$ ~$ ls -la /lib64/
total 8
drwxr-xr-x  2 root root 4096 Oct 13 03:37 .
drwxr-xr-x 14 root root 4096 Oct 13 03:37 ..
lrwxrwxrwx  1 root root   42 Sep 28 08:38 ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2

This is a symlink, just recreating the symlink should be enough, but since commands don't work anymore, you'll have to do this from a live-session.

muru avatar
us flag
You should try `ls -la /lib64/`, since it looks like OP entered the directory before deleting everything in it.
mook765 avatar
cn flag
@muru I don't see any difference between `ls -la /lib64` and `ls -la /lib64/`.
muru avatar
us flag
That is rather strange. The second option should list the contents of the target directory of the symlink (the contents that OP in this case has removed). `ls -laH /lib64/`, then if your `ls` might be an alias that has an option breaking that behaviour.
mook765 avatar
cn flag
@muru Yes, I see this now, you are right. Because `/lib64` is not a folder but a symlink... edited...
Score:1
in flag

The /lib64 directory contains shared libraries that are needed for dynamically linked executables. These share common code in shared libraries rather than copying it into each executable. Things like shell scripts would probably also not work, as those run commands that may be broken.

The commands that work are either built into your shell (like cd and echo) or are statically linked. The busybox command is by design statically linked and has abbreviated versions of many commands built into it.

Damage to system directories like /lib64 are near fatal to a unix system. To restore functionality, you need to restore the missing files. Options to do this would include:

  • restore from backup
  • reinstalling the deb files they came from
  • copying the files from another identical system with the same version of the operating system
  • boot from a live install disk and use tools on the live disk to replace the missing files
  • completely reinstall the operating system (back up data first)

It may be possible to do a partial restore and then use something like dpkg -V to get a list of things that are different or missing from the stock files and reinstall some of the damaged packages with apt install --reinstall. Unfortunately, dpkg and the tools it uses all rely on shared libraries, so at least the critical ones have to be there before this helps.

Sadly, in situations like this, it is frequently faster and easier to reinstall from scratch than repair the damage.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.