I am facing a problem with my terminal (Ubuntu 12.04 LTS) . I was making some changes in the /bin/bash , but I have keeped a backup of .bashrc in case of something went wrong. Anyway today I have tried to open my Terminal and the following message appeared:

There was an error creating the child process for this terminal Failed to execute child process "/bin/bash" (Too many levels of symbolic links)

What can I do in order to fix this problem or how can I reset my Terminal to defaults ??

Thanks In advance

Dani AI

Generated

This error happens before .bashrc is read, so your backup of that file will not help until /bin/bash itself resolves correctly. As noted, it is almost always a symlink problem on the path to /bin/bash (often a loop like /bin/bash -> /bin/sh -> /bin/bash). is also right that it can be a long symlink chain even without a loop. First job is to map the chain precisely.

If you can reach a recovery shell (GRUB > Advanced options > recovery mode > root), remount rw and inspect the links:

mount -o remount,rw /
namei -lx /bin/bash
readlink -v /bin/bash
readlink -f /bin/bash || echo "fails to resolve"
ls -l /bin/bash /bin/sh

If /bin/bash is a symlink, or a loop is shown, replace it with the real binary from the package. Easiest fix:

mv -v /bin/bash /bin/bash.bad  # keep a copy just in case
apt-get update
apt-get --reinstall install bash

If the filesystem is mounted read-only, run the mount command above first. If apt refuses to run because you are in a minimal shell, you can boot a Live USB, mount your root partition, chroot, and reinstall:

sudo mount /dev/sdXN /mnt
sudo mount --bind /dev /mnt/dev && sudo mount --bind /proc /mnt/proc && sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
apt-get update && apt-get --reinstall install bash

Extra safety tips: as suggested, verify after the fix:

file /bin/bash
/bin/bash --version
type -a bash

Finally, if login shells are still broken, temporarily switch your user to dash and log in to clean up any shell configs, then switch back:

usermod -s /bin/dash youruser
# later
chsh -s /bin/bash youruser

’s launcher trick is fine for app startup, but it will not repair a broken /bin/bash.

Recommended Answers

All 5 Replies

I think you should use following script like:

!/bin/bash

XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae
You can also create the launcher using the following command:

bash -c 'XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae'
Setting environment variables before the executable file name in a command line is a feature of CLI (Command Line Interface) shells. If you put VARIABLE=value /path/to/executable in a launcher, the program that reads the launcher (and effectively launch the executable) will try to find a file named "VARIABLE=value" and, of course, will fail.

That command launches bash, the default user shell in Ubuntu, and tell it to execute (the -c option) the string "XLIB_SKIP_ARGB_VISUALS=1 /opt/softwaresname/abaqus cae", so it will be interpreted like it is when you type that in the CLI.

If you only changed the file .bashrc, why don't you simply restore the backup to see if it works ?

If following Gribouillis's doesn't solve the problem:

If you can get to any terminal of any sort (chrooting's awesome for moments like these) then run ls -l /bin/bash to see if that's a symlink and what it's pointing to.

An error like "too many levels of symbolic links" means that you must have a recursive (i.e., circular) set of symlinks. In other words, you must have created a symlink (maybe for .bashrc or /bin/bash) which directly or indirectly refers back to itself. When that happens, the OS follows the symbolic links which go round and round in a circle, until the OS reaches a limit on how far it will keep doing that. The main reason for this limit to exist is for this particular situation (circular symlinks), because it could cause the kernel to hang indefinitely (infinite loop) if there was no limit.

Now that you understand what the problem is, there is a good chance you already know what you did wrong.

If not, try to investigate what symlinks you have created (intentionally or not) surrounding .bashrc and /bin/bash (two things that you should not mess with!).

If you have trouble reaching a usable terminal because of this, here are some tricks, off the top of my head:

1) Boot into the root shell. This shouldn't use your user account's .bashrc file. The disadvantage is that this environment kind of crude (no GUI at all).
2) You can install an and use that one instead of bash. Most of them are nearly identical to bash, but shouldn't use the .bashrc file or the /bin/bash program.
3) Create a new user account (throught the Ubuntu system setting menus) with sudo-privileges. Log-in with that user-account and open a terminal. This should avoid using the "corrupt" .bashrc file.
4) Boot into a live CD/USB and use the terminal in there, which will use the original /bin/bash from the LiveCD and the default .bashrc (if any) from there as well. This will allow you to navigate and manipulate your installation's file system.

I'm not sure too many levels automatically means circular links. There are various limits for the number of levels.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.