4

I am working on AIX 6.1 and inadvertently renamed /usr/lib/libc.a to usr/lib/libc.a_ Just as I renamed I realized my stupid mistake. Almost all of the commands mv, cp, ftp etc ( except cd ) have stopped working.

How shall I rename by libc.a back. Without it, the system hardly functions sanely :(

  • 2
    Try every possible way to fix it and be imaginative. You can do it with `dd`, `cat`, `ln`, and probably a dozen other commands. Check your list of shell internals (`read -N`?). Are any servers already running that could be made to do it? – David Schwartz Apr 04 '12 at 11:50
  • @DavidSchwartz Actually I was running on a virtualized environment of AIX. I mean I was running on one of the several partitions on a single server – Pavan Manjunath Apr 04 '12 at 12:07
  • Got Busybox? That might do it. – Tom O'Connor Apr 04 '12 at 12:27
  • I am not proficient on AIX but does not a `.a` suffix mean a _static_ library? Is it possible that you have messed up the shared libc file too? BTW, `cd` is a command embedded to the shell – adamo Apr 04 '12 at 15:23

5 Answers5

3

Most of the binaries depend/use on the libc library. To find out, you can use ldd /path/to/binary It seems that you need to boot another image or live CD. Then, you can mount the relevant partition (/usr if it is separated or /) and rename the file.

Khaled
  • 35,688
  • 8
  • 69
  • 98
  • [the ldd utility is not a part of the normal AIX OS install](https://www-304.ibm.com/support/docview.wss?uid=swg21162912) ... – adamo Apr 04 '12 at 15:32
2

Just posting this in case someone else searches for this issue.

Since at least AIX 5.3 IBM has provided the recovery shell recsh just for this issue.

Check IBM Documentation.

Example of use: recsh; cp -p libc.a.new /usr/lib/libc.a; exit

1

I guess ln is out of question, too?

ln -s usr/lib/libc.a_ usr/lib/libc.a

Or Perl?

perl -e 'symlink("usr/lib/libc.a_","usr/lib/libc.a");'

or

perl -MFile::Copy -e 'copy("usr/lib/libc.a_","usr/lib/libc.a");'
Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
1

Try while read -r x; do echo $x >> libc.a; done < libc.a_ (This assumes a Bourne style shell).

If it fails and you are lucky enough that ed or sed are statically linked try:

sed libc.a_ > libc.a

or

ed libc.a_
w libc.a
q

also dd if=libc.a_ of=libc.a

adamo
  • 6,867
  • 3
  • 29
  • 58
0

Boot from rescue disk, mount filesystem, do rename.

psusi
  • 3,247
  • 1
  • 16
  • 9