How to restore mistakenly deleted tree commands
How to restore mistakenly deleted tree commands
Examine the usage of rpm,yum
Delete the tree command. The tree command is not available
[root@centos7 ~] # which tree
/ usr/bin/tree
[root@centos7] # rm-f / usr/bin/tree
[root@centos7] # tree.
Bash: tree: command not found...
Direct yum or rpm installation will prompt tree that it has been installed
[root@centos7 ~] # yum install tree
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Base: mirror.bit.edu.cnextras: mirrors.tuna.tsinghua.edu.cnupdates: mirrors.tuna.tsinghua.edu.cn
Base | 3.6 kB 00:00:00
Extras | 3.4 kB 00:00:00
Nginx | 2.9 kB 00:00:00
Updates | 3.4 kB 00:00:00
Package tree-1.6.0-10.el7.x86_64 already installed and latest version
Nothing to do
[root@centos7] # rpm-ivh / misc/cd/Packages/tree-1.6.0-10.el7.x86_64.rpm
Preparing... # # [100%]
Package tree-1.6.0-10.el7.x86_64 is already installed
Solution: mandatory override installation
[root@centos7] # rpm-- help
-- replacepkgs reinstall if the package is already present
[root@centos7] # rpm-ivh / misc/cd/Packages/tree-1.6.0-10.el7.x86_64.rpm-- replacepkgs
Preparing... # # [100%]
Updating / installing...
1:tree-1.6.0-10.el7 # # [100%]
4. Tree can be used at this time.
[root@centos7] # tree. -d
.
├── Desktop
├── Documents
├── Downloads
├── Music
├── Pictures
├── Public
├── scripts
├── Templates
└── Videos
9 directories
5. Yum can be reinstalled
[root@centos7] # yum-- help
Reinstall reinstall a package
[root@centos7] # rm-f / usr/bin/tree
[root@centos7] # tree-d.
-bash: / usr/bin/tree: No such file or directory
[root@centos7 ~] # yum reinstall tree-y
[root@centos7] # tree-d.
.
├── Desktop
├── Documents
├── Downloads
├── Music
├── Pictures
├── Public
├── scripts
├── Templates
└── Videos
9 directories
Of course, you can also find tree's rpm package, use rpm2cpio and cpio-id to extract the package, and move the tree command back to its original location