导航:首页 > 操作系统 > linuxbin误删

linuxbin误删

发布时间:2025-06-16 15:41:53

linux服务器下误删除文件的解决方法

服务器误删了/usr/bin和/usr/sbin目录,然后,从别的地方拷贝这两个目录过来,发现可能很多是链接等非普通文件,可拷贝的时候对链接的处理不知道应加什么参数,所以,一百多兆的东西拷贝了近一个G;最后,先给tar了一下,在拷贝。
这样,服务器基本弄好,建议:
1.不要直接用root登入,特别是不熟悉的人。
2.建议需要执行root权限命令的使用sudo,少用su;
3.可用visudo来配置需要执行的root权限命令
eg: xxx ALL=/sbin/mount,/sbin/unmount,/sbin/ifconfig NOPASSWD: ALL
rm命令不行;但是,还有“后遗症”:
1.登入时,'linux': unknown terminal type;
2.使用top, clear (知道的)时, 因为 terminal type问题;
3.vim也是类似问题,不可操作;已解决,但只能用基本模式;
4.tftp、telnet服务,已解决。

⑵ 我在linux下敲了一条 mv*的命令,结果文件夹(比如usr,bin等等)全都不见了,该怎么恢复

你在那个路径,用ls -a 查看所有文件, 应该有个隐藏文件夹,文件应该都在里面。直接mv出来就可以了,你用mv * 意思是把本文件的所有文件放到最后一个文件夹中。

⑶ 在linux系统下用rm命令误删了一个文件,怎样才能恢复这个文件

1、先要进行重启ubuntu,随即长按shirft进入grub菜单,这时候注意的是再进行选择recovery mode,按"e"键进入编辑页面,如下图所示。


⑷ linux误删/bin目录怎么办

解决思路:
1、找一台操作系统环境相同的机器,拷贝目录到该机器。
2、估计的重新安装内核,因为找不到内核映射了。
详细解决步骤如下:
1、重新启动机器,插入光盘,进入带网络环境的救援模式。
2、把另外一个系统的bin目录的压缩包拷贝过来,然后解压
3、因为系统内核丢失了,所以我们需要先安装内核,在安装内乱漏明核时会自动生成initrd
a、cd /mnt/
b、mkdir cd
c、mount -t iso9660 -o ro /dev/hda /mnt/cd/ (注意,使用dmesg命令详细查看光驱挂载的设备,我的是/dev/hda)
d、rpm -Uvh --force kernel-2.6.18-164.el5.i686.rpm
4、安装grub
a、grup-install /dev/sda
5、编辑grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda7
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-164.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-164.el5.img
注意搜核,如果你是逻辑卷需要修改根目录的标签,我的是逻辑卷。
6,重新启动系统
重新启动系统未成功,出现以下错误:
mount: could not find filesystem '/dev/root'
setuproot: moving /哗告dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
经过搜索后,发现此类问题多集中在逻辑卷管理的情况,具体原因是我们在重新安装内核的时候,没有加载一些逻辑卷,解决方法如下:
1) Boot with the rescue CD
2) Type 'chroot /mnt/sysimage'
3) 'cd /boot'
4) 'mkdir newinit'
5) 'cd newinit'
6) 'gunzip -c ../initrd-2.6.18-164.el5.img | cpio -idmv'
7) 'vi init'
8) Find 'mount /sysroot'
9) Delete or comment this out
10) Replace with 'mount -o defaults --ro -t ext3 /dev/VolGroup00/LogVol00 /sysroot' where /dev/VolGroup00/LogVol00 is the mount point for /
11) ':wq' out of vi
12) 'find . | cpio --quiet -c -o >../newinitrd'
13) 'cd ..' - you are now in /boot
14) 'mv initrd-2.6.18-164.el5.img initrd-2.6.18-164.el5.img.bak' - backup current initrd img file
15) 'gzip -9 < newinitrd > initrd-2.6.18-164.el5.img'
16) Reboot the computer without the CD
再次重新启动系统,OK,问题解决。
7、尝试进行远程连接,因为远程服务器不允许root直接连接,可以用普通用户进行登录,登录后执行 su - root 命令,输入密码总是提示密码错误,但是在终端直接用root是可以登录的,奇怪,后来发现问题出在 su 命令上,是文件权限粘贴位的问题,因为拷贝过来的su命令权限如下:
[root@localhost ~]# ll /bin/su
-rwxr-xr-x 1 root root 23960 Oct 18 21:46 /bin/su
正确如下:
[root@localhost ~]# ll /bin/su
-rwsr-xr-x 1 root root 23960 Oct 18 21:46 /bin/su
这样就简单了,设置粘贴位如下:
[root@localhost ~]# chmod u+s mount
除了su命令外,还有另外几个需要设置粘贴位,mount,ping,ping6,traceroute,traceroute6,umount。
另外还要注意一些软连接。

阅读全文

与linuxbin误删相关的资料

热点内容
怎么把pdf转ppt 浏览:392
单片机在广告灯的应用 浏览:764
stringjavautf8 浏览:731
硬盘优盘加密工具推荐 浏览:874
服务器一般怎么安装驱动 浏览:986
单轴多级离心式压缩机 浏览:314
买了云服务器可以干什么 浏览:622
用iView开发的源码 浏览:712
拍多肉app哪个好 浏览:881
java数组访问 浏览:538
在通信过程中待加密 浏览:271
孩子挂社保在哪里app 浏览:340
身份证识别软件源码 浏览:875
cad抠图命令健 浏览:281
cad2010填充命令 浏览:546
车载u盘mv不能显示文件夹 浏览:794
rtp加密传输 浏览:936
公众号平台源码下载 浏览:769
android设置网络代理 浏览:460
dir命令dos 浏览:218