No command executes when i deleted /lib64

Solution 1:

/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.

Solution 2:

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.