我不小心删除了/bin/hostname。我暂时在那里放置了一个返回已知名称的 shell 脚本。但如何恢复丢失的二进制文件呢?
它是一个 AWS AMI。
Linux ip-10-2-0-162 3.4.62-53.42.amzn1.x86_64 #1 SMP Fri Sep 20 07:23:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
答案1
除了从另一个实例复制文件之外,您还可以重新安装该包(通过yum reinstall $package
),例如:
[root@localhost ~]# rpm -qf /bin/hostname
net-tools-1.60-110.el6_2.x86_64
[root@localhost ~]# ls -l /bin/hostname
ls: cannot access /bin/hostname: No such file or directory
[root@localhost ~]# yum reinstall net-tools
(...)
Running Transaction
Installing : net-tools-1.60-110.el6_2.x86_64 1/1
Verifying : net-tools-1.60-110.el6_2.x86_64 1/1
Installed:
net-tools.x86_64 0:1.60-110.el6_2
Complete!
[root@localhost ~]# ls -l /bin/hostname
-rwxr-xr-x 1 root root 13712 May 10 2012 /bin/hostname