LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Centos 6 suddenly yum and other command are not found (https://www.linuxquestions.org/questions/linux-server-73/centos-6-suddenly-yum-and-other-command-are-not-found-4175652220/)

newbie14 04-16-2019 12:33 AM

Centos 6 suddenly yum and other command are not found
 
I have an old centos 6 box been running sometime. Today I went to run yum update suddenly it say command not found. I run this command bash bash
bash: /usr/bin/tty: No such file or directory
My current path is
echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/sbin

What could be the solution to this issue ?

tyler2016 04-16-2019 06:20 AM

Please paste things from your terminal into code tags. I don't know what this means:

Code:

I run this command bash bash
bash: /usr/bin/tty: No such file or directory

If you get that when trying to do this:

Code:

tyler@desktop:~$ bash
tyler@desktop:~$

Then your .bashrc is trying to run /usr/bin/tty which doesn't exists on your system. What is the result of this command:

Code:

while read line; do echo $line;  done < /etc/mtab
This is how you can "cat" a file using bash if you think your filesystem or disk may be hosed.

newbie14 04-17-2019 09:49 AM

Hi Tyler,
What I meant by this
Code:

I run this command bash bash
bash: /usr/bin/tty: No such file or directory

What I just typed in the command line bash and I got this this output
Code:

bash: /usr/bin/tty: No such file or directory
I ran this command and go this output.

Code:

while read line; do echo $line;  done < /etc/mtab
/dev/mapper/VolGroup-LogVol01 / ext4 rw 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs rw 0 0
/dev/md0 /boot ext4 rw 0 0
/dev/mapper/VolGroup-LogVol03 /tmp ext4 rw 0 0
/dev/mapper/VolGroup-LogVol02 /usr ext4 rw 0 0
/dev/mapper/VolGroup-LogVol04 /var ext4 rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0

My echo $PATH results is

Code:

echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

What should I do to to recover it like previously?

tyler2016 04-17-2019 10:00 AM

Do any commands work? Do you get anything when you try to run basic stuff like ls and df?

berndbausch 04-17-2019 10:42 AM

Quote:

Originally Posted by newbie14 (Post 5985452)
bash: /usr/bin/tty: No such file or directory

Did you check whether /usr/bin/tty exists? Is it executable?
Code:

$ ls -l /usr/bin/tty
$ file /usr/bin/tty

Same for yum. I am not sure where it is supposed to be located; I would try /bin, /usr/bin, /sbin, /usr/sbin.

newbie14 04-20-2019 11:36 PM

Hi Tyler

Quote:

Originally Posted by tyler2016 (Post 5985932)
Do any commands work? Do you get anything when you try to run basic stuff like ls and df?

Yes both this ls and df are working as per normal.

newbie14 04-20-2019 11:41 PM

Hi Berndbausch
Quote:

Originally Posted by berndbausch (Post 5985951)
Did you check whether /usr/bin/tty exists? Is it executable?
Code:

$ ls -l /usr/bin/tty
$ file /usr/bin/tty

Same for yum. I am not sure where it is supposed to be located; I would try /bin, /usr/bin, /sbin, /usr/sbin.


For this command I got this results.

Code:

ls -l /usr/bin/tty
ls: cannot access /usr/bin/tty: No such file or directory

I tried all your combination of
Code:

/bin, /usr/bin, /sbin, /usr/sbin
all gave me
Code:

ls: cannot access /usr/sbin/yum: No such file or directory
But when I ran this command
Code:

ls -l /usr/sbin
I could see part of the results as


Code:

-rwxr-xr-x  1 root root      9932 Jul 30  2018 yum-complete-transaction
-rwxr-xr-x  1 root root      8022 Jul 30  2018 yumdb


berndbausch 04-21-2019 12:26 AM

I can't say why they are missing, but their absence explains your problem.

Without yum, it will be hard to install anything. Is reinstallation an option?

tyler2016 04-21-2019 05:19 AM

If a reinstall isn't an option, you might be able to get by downloading packages manually and installing them with rpm. Do you have rpm? I can't remember where it is at, but try the usual locations: /sbin, /usr/sbin, /bin, and /usr/bin. If you go this route would start with glibc followed by coreutils, as I think tty is part of coreutils.

newbie14 04-22-2019 04:20 AM

Hi Berndbaucsh,
Yes their absence is a big problem cause I cant run any yum update etc. I cant do much installation. I am trying to avoid reinstallation cause many things running on it.

newbie14 04-22-2019 04:21 AM

Hi Tyler,
So what you want me to do is rpm is it? I dont get you what do you mean by start glibc ?

tyler2016 04-22-2019 06:01 AM

Considering yum and parts of coreutils are gone, this is a long shot, but might work. I am assuming you are using CentOS and not RHEL, SL, or some other RHEL like clone. I am assuming you have a good backup and an OS reinstall is not possible. Here is the URL for the package files:

http://mirror.centos.org/centos/6/os/x86_64/Packages/

Download the latest versions of the following packages. I might have missed a few, but this should be what you need to get yum working again:

audit-libs
bash
bzip2-libs
coreutils
cracklib
cracklib-dicts
curl
cyrus-sasl-lib
db4
db4-utils
elf
elfutils-libelf
expat
file-libs
gdbm
glibc
gmp
gpgme
grep
info
krb5-libs
libacl
libattr
libcap
libcap
libcom_err
libcurl
libcurl
libffi
libidn
libselinux
libssh2
lua
ncurses
ncurses-libs
nspr
nss
nss-util
openldap
openssl
pam
popt
pygpgme
python
python-iniparse
python-libs
python-pycurl
python-urlgrabber
readline
rpm
rpm-libs
rpm-python
sqlite
xz-libs
yum
zlib

Put them all in a single directory and install them with:

Code:

cd /where/you/put/them
rpm -i --force --nodeps *.rpm

When you are done do this to reinstall all of your packages which should resolve any other missing file problems:

Code:

yum reinstall '*'
If this doesn't work, which it may not, since tty is part of coreutils, you could do a fresh minimal install of CentOS 6 in a VM, and rsync /bin, /sbin, /lib, /usr, and /lib64 to the broken system and then do a yum reinstall '*'. If you can't rsync, get them to a broken host IN A TEMPORARY ROOT by whatever means you have, and chmod +x everything to ensure you aren't stuck with programs you can't execute and have no way of fixing. Once they are there and the permissions are fixed, cp -p all of the regular files in the alternate root to their correct locations. Some suggestions: nc, tar, scp, ftp, cpio, zip/unzip. Don't worry about permissions exact permissions, they will be fixed when you reinstall the packages.

newbie14 04-23-2019 01:45 AM

Hi Tyler,
Lucky the rpm is working but wget not working. So I download to my local win and then upload the folder and ran this command
Quote:

rpm -i --force --nodeps *.rpm
without any issue.

Next when I tried to run yum reinstall '*'
I got stuck as below.
Quote:


--> Finished Dependency Resolution
Error: Multilib version problems found. This often means that the root
cause is something else and multilib version checking is just
pointing out that there is a problem. Eg.:

1. You have an upgrade for nss which is missing some
dependency that another package requires. Yum is trying to
solve this by installing an older version of nss of the
different architecture. If you exclude the bad architecture
yum will tell you what the root cause is (which package
requires what). You can try redoing the upgrade with
--exclude nss.otherarch ... this should give you an error
message showing the root cause of the problem.

2. You have multiple architectures of nss installed, but
yum can only see an upgrade for one of those arcitectures.
If you don't want/need both architectures anymore then you
can remove the one with the missing update and everything
will work.

3. You have duplicate versions of nss installed already.
You can use "yum check" to get yum show these errors.

...you can also use --setopt=protected_multilib=false to remove
this checking, however this is almost never the correct thing to
do as something else is very likely to go wrong (often causing
much more problems).

Protected multilib versions: nss-3.36.0-9.el6_10.x86_64 != nss-3.36.0-8.el6.x86_64
Error: Protected multilib versions: yum-3.2.29-81.el6.centos.0.1.noarch != yum-3.2.29-81.el6.centos.noarch
[root@localhost recover]#

What you suggest here?

tyler2016 04-23-2019 04:49 AM

Try:

Code:

yum update
yum reinstall '*'


newbie14 04-23-2019 10:08 AM

Hi Tyler,
Infact I already tried that
Quote:

yum update
works fine. The error comes when I ran this
Quote:

yum reinstall '*'


All times are GMT -5. The time now is 11:16 PM.