zoukankan      html  css  js  c++  java
  • debugfs linux rm 删除 恢复 Attempt to read block from filesystem resulted in short read while opening filesystem

    w

    删除具有空字符的文件

    反斜杠来转义下一个字符

    rm -R  Samples - Copy 

    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ ls
    Client.php  Exception.php  Function.Business.php  Interface.php  Mock  Mock.php  Model  Model.php  Samples  Samples - Copy  Show
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ cp -R Samples Samples_rm
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ ls
    Client.php  Exception.php  Function.Business.php  Interface.php  Mock  Mock.php  Model  Model.php  Samples  Samples - Copy  Samples_rm  Show
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ cd Samples/ -/ Copy 
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders/Samples$ cd ..
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ cd Samples - Copy 
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders/Samples - Copy$ cd ..
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ cd Samples - Copy 
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders/Samples - Copy$ cd ..
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ rm -R  Samples - Copy 
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ ll
    total 112
    drwxr-xr-x 7 well well  4096 May  4 20:21 ./
    drwxr-xr-x 3 root root  4096 May  4 19:45 ../
    -rwxrwxrwx 1 well well 36520 Apr 10 12:03 Client.php*
    -rwxrwxrwx 1 well well  5033 Mar  2 12:41 Exception.php*
    -rwxrwxrwx 1 well well  3542 Apr 24 16:24 Function.Business.php*
    -rwxrwxrwx 1 well well  4708 Mar  2 12:41 Interface.php*
    drwxrwxrwx 2 well well  4096 May  4 19:47 Mock/
    -rwxrwxrwx 1 well well  6437 Mar  2 12:41 Mock.php*
    drwxrwxrwx 2 well well  4096 May  4 19:47 Model/
    -rwxrwxrwx 1 well well 17734 Mar  2 12:41 Model.php*
    drwxrwxrwx 2 well well  4096 May  4 20:13 Samples/
    drwxrwxr-x 2 well well  4096 May  4 20:18 Samples_rm/
    drwxrwxrwx 2 well well  4096 Apr 10 09:51 Show/
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ 

    Linux下如何处理包含空格和特殊字符的文件名 - 51CTO.COM
    http://os.51cto.com/art/201507/483983_all.htm

    Linux下如何处理包含空格和特殊字符的文件名
    2015-07-13 11:28 Avishek Kumar LCTT 字号:T | T
    一键收藏,随时查看,分享好友!
    我们经常会看到文件名和文件夹名。大多数时候文件/文件夹的名字和内容相关并以数字和字母开头。字母加数字的文件名最常见,应用也很广泛,但总会需要处理一些包含特殊字符的文件名/文件夹名。本文作者已经尝试覆盖你可能碰到的所有情况。大多数测试都在BASH Shell里完成,可能在其他shell下会有差异。 
    我们经常会看到文件名和文件夹名。大多数时候文件/文件夹的名字和内容相关并以数字和字母开头。字母加数字的文件名最常见,应用也很广泛,但总会需要处理一些包含特殊字符的文件名/文件夹名。

    注意:我们可能有各种类型的文件,但是为了简单以及方便实现,在本文中我们只用文本文件(.txt)做演示。

    最常见的文件名例子:

    abc.txt
    avi.txt
    debian.txt
    ...
    数字文件名例子:

    121.txt
    3221.txt
    674659.txt
    ...
    字母数字文件名例子:

    eg84235.txt
    3kf43nl2.txt
    2323ddw.txt
    ...
    包含特殊字符的文件名的例子,并不常见:

    #232.txt
    #bkf.txt
    #bjsd3469.txt
    #121nkfd.txt
    -2232.txt
    -fbjdew.txt
    -gi32kj.txt
    --321.txt
    --bk34.txt
    ...
    一个显而易见的问题是 - 在这个星球上有谁会创建和处理包含井号(#),分号(;),破折号(-)或其他特殊字符的文件/文件夹啊!

    我和你想的一样,这种文件名确实不常见,不过在你必须得处理这种文件名的时候你的 shell 也不应该出错或罢工。而且技术上来说,Linux 下的一切比如文件夹、驱动器或其他所有的都被当作文件处理。

    处理名字包含破折号(-)的文件
    创建以破折号(-)开头的文件,比如 -abx.txt。

    $ touch -abc.txt
    测试输出
    touch: invalid option -- 'b'
    Try 'touch --help' for more information.
    出现上面错误的原因是,shell 把破折号(-)之后的内容认作参数了,而很明显没有这样的参数,所以报错。

    要解决这个问题,我们得告诉 Bash shell(是的,这里以及本文后面的大多数例子都是基于 BASH 环境)不要将特殊字符(这里是破折号)后的字符解释为参数。

    有两种方法解决这个错误:

    $ touch -- -abc.txt [方法 #1]
    $ touch ./-abc.txt [方法 #2]
    你可以通过运行命令 ls 或 ls -l 列出详细信息来检查通过上面两种方式创建的文件。

    $ ls -l

    total 0
    -rw-r--r-- 1 avi avi 0 Jun 8 11:05 -abc.txt
    要编辑上述文件可以这样:

    $ nano -- -abc.txt
    或者
    $ nano ./-abc.txt
    注意:你可以将 nano 替换为任何其他你喜欢的编辑器比如说 vim:

    $ vim -- -abc.txt
    或者
    $ vim ./-abc.txt
    如果只是简单地移动文件可以这样:

    $ mv -- -abc.txt -a.txt
    或者
    $ mv -- -a.txt -abc.txt
    删除这种文件,可以这样:

    $ rm -- -abc.txt
    或者
    $ rm ./-abc.txt
    如果一个目录下有大量这种名字包含破折号的文件,要一次全部删除的话,可以这样:

    $ rm ./-*
    重要:

    上面讨论的规则可以同样应用于名字中包含任意数量以及任意位置的连接符号的文件。就是说,-a-b-c.txt,ab-c.txt,abc-.txt,等等。

    上面讨论的规则可以同样应用于名字中包含任意数量以及任意位置连接符号的文件夹,除了一种情况,在删除一个文件夹的时候你得这样使用rm -rf:

    $ rm -rf -- -abc 或者 $ rm -rf ./-abc

    处理名字包含井号(#)的文件
    符号#在 BASH 里有非常特别的含义。#之后的一切都会被认为是评论,因此会被 BASH 忽略。

    通过例子来加深理解:

    创建一个名字是 #abc.txt 的文件:

    $ touch #abc.txt
    测试输出
    touch: missing file operand
    Try 'touch --help' for more information.
    出现上面错误的原因是,BASH 将 #abc.txt 解释为评论而忽略了。所以命令 touch没有收到任何文件作为参数,所以导致这个错误。

    要解决这个问题,你可能需要告诉 BASH 不要将 # 解释为评论。

    $ touch ./#abc.txt
    或者
    $ touch '#abc.txt'
    检查刚创建的文件:

    $ ls -l

    total 0
    -rw-r--r-- 1 avi avi 0 Jun 8 12:14 #abc.txt
    现在创建名字中除了开头的其他地方包含 # 的文件。

    $ touch ./a#bc.txt
    $ touch ./abc#.txt
    或者
    $ touch 'a#bc.txt'
    $ touch 'abc#.txt'
    运行 ‘ls -l‘ 来检查:

    $ ls -l

    total 0
    -rw-r--r-- 1 avi avi 0 Jun 8 12:16 a#bc.txt
    -rw-r--r-- 1 avi avi 0 Jun 8 12:16 abc#.txt
    如果同时创建两个文件(比如 a 和 #bc)会怎么样:

    $ touch a.txt #bc.txt
    检查刚创建的文件:

    $ ls -l

    total 0
    -rw-r--r-- 1 avi avi 0 Jun 8 12:18 a.txt
    很明显上面的例子中只创建了文件 a 而文件 #bc 被忽略了。对于上面的情况我们可以这样做,

    $ touch a.txt ./#bc.txt
    或者
    $ touch a.txt '#bc.txt'
    检查一下:

    $ ls -l

    total 0
    -rw-r--r-- 1 avi avi 0 Jun 8 12:20 a.txt
    -rw-r--r-- 1 avi avi 0 Jun 8 12:20 #bc.txt
    可以这样移动文件:

    $ mv ./#bc.txt ./#cd.txt
    或者
    $ mv '#bc.txt' '#cd.txt'
    这样拷贝:

    $ cp ./#cd.txt ./#de.txt
    或者
    $ cp '#cd.txt' '#de.txt'
    可以使用你喜欢的编辑器来编辑文件:

    $ vi ./#cd.txt
    或者
    $ vi '#cd.txt'

    $ nano ./#cd.txt
    或者
    $ nano '#cd.txt'
    这样删除:

    $ rm ./#bc.txt
    或者
    $ rm '#bc.txt'
    要删除所有以井号(#)开头的文件,可以这样:

    # rm ./#*
    处理名字包含分号(;)的文件
    如果你还不知道的话,分号在 BASH 里起到命令分隔的作用,其他 shell 可能也是一样的。分号作为分隔符可以让你一次执行几个命令。你碰到过名字包含分号的文件吗?如果没有的话,这里有例子。

    创建一个名字包含分号的文件。

    $ touch ;abc.txt
    测试输出
    touch: missing file operand
    Try 'touch --help' for more information.
    bash: abc.txt: command not found
    出现上面错误的原因是,在运行上面命令的时候 BASH 会把 touch 解释为一个命令但是在分号前没有任何文件参数,所以报告错误。然后报告的另一个错误找不到命令 abc.txt,只是因为在分号后 BASH 会期望另一个新的命令,而 abc.txt 并不是一个命令。

    要解决这个问题,我们得告诉 BASH 不要将分号解释为命令分隔符,例如:

    $ touch ./';abc.txt'
    或者
    $ touch ';abc.txt'
    注意:我们将文件名用单引号 '' 包含起来。这样可以告诉 BASH 分号 ; 是文件名的一部分而不是命令分隔符。

    对名字包含分号的文件和文件夹的其他操作(就是,拷贝、移动、删除)可以直接将名字用单引号包含起来就好了。

    处理名字包含其他特殊字符的文件/文件夹
    文件名包含加号 (+)
    不需要任何特殊处理,按平时的方式做就好了,比如下面测试的文件名。

    $ touch +12.txt
    文件名包含美元符 ($)
    你需要将文件名用单引号括起来,像处理分号那样的方式。然后就很简单了。

    $ touch '$12.txt'
    文件名包含百分号 (%)
    不需要任何特殊处理,当作一个普通文件就可以了。

    $ touch %12.txt
    文件名包含星号 (*)
    需要用单引号括起来或使用反斜杠转义。(LCTT 译注:此处原文有误,已修改。)

    $ touch *12.txt
    注意:当你需要删除星号开头的文件时,千万不要用类似下面的命令。

    $ rm *
    或者
    $ rm -rf *
    而是用这样的命令,(LCTT 译注:此处原文有误,已修改)

    $ rm ./'*.txt'
    文件名包含叹号 (!)
    只要将文件名用单引号括起来,其他的就一样了。

    $ touch '!12.txt'
    文件名包含小老鼠 (@)
    没有什么特别的,可以将名字包含小老鼠的文件当作普通文件。

    $ touch '@12.txt'
    文件名包含 ^
    不需要特殊处理。可以将名字包含 ^ 的文件当作普通文件。

    $ touch ^12.txt
    文件名包含 (&)
    将文件名用单引号括起来,然后就可以操作了。

    $ touch '&12.txt'
    文件名包含括号 ()
    如果文件名包含括号,你需要将文件名用单引号括起来。

    $ touch '(12.txt)'
    文件名包含花括号 {}
    用单引号括起来或使用反斜杠转义。(LCTT 译注:此处原文有误,已修改)

    $ touch '{12.txt}'
    文件名包含尖括号 <>
    名字包含尖括号的文件需要用单引号括起来。

    $ touch '<12.txt>'
    文件名包含方括号 [ ]
    用单引号括起来或使用反斜杠转义。(LCTT 译注:此处原文有误,已修改)

    $ touch '[12.txt]'
    文件名包含下划线 (_)
    这个非常普遍,不需要特殊对待。当作普通文件随意处理。

    $ touch _12.txt
    文件名包含等号 (=)
    用单引号括起来或使用反斜杠转义。(LCTT 译注:此处原文有误,已修改)

    $ touch '=12.txt'
    处理反斜杠 ()
    反斜杠会告诉 shell 忽略后面字符的特殊含义。你必须将文件名用单引号括起来,就像处理分号那样。其他的就没什么了。

    $ touch '12.txt'
    包含斜杠的特殊情形
    除非你的文件系统有问题,否则你不能创建名字包含斜杠的文件。没办法转义斜杠。

    所以如果你能创建类似 ‘/12.txt’ 或者 ‘b/c.txt’ 这样的文件,那要么你的文件系统有问题,或者支持 Unicode,这样你可以创建包含斜杠的文件。只是这样并不是真的斜杠,而是一个看起来像斜杠的 Unicode 字符。

    文件名包含问号 (?)
    用单引号括起来或使用反斜杠转义。(LCTT 译注:此处原文有误,已修改)

    $ touch '?12.txt'
    文件名包含点 (.)
    在 Linux 里以点 (.) 开头的文件非常特别,被称为点文件。它们通常是隐藏的配置文件或系统文件。你需要使用 ls 命令的 ‘-a‘ 或 ‘-A‘ 开关来查看这种文件。

    创建,编辑,重命名和删除这种文件很直接。

    $ touch .12.txt
    注意:在 Linux 里你可能碰到名字包含许多点 (.) 的文件。不像其他操作系统,文件名里的点并不意味着分隔名字和扩展后缀。你可以创建名字包含多个点的文件:

    $ touch 1.2.3.4.5.6.7.8.9.10.txt
    检查一下:

    $ ls -l

    total 0
    -rw-r--r-- 1 avi avi 0 Jun 8 14:32 1.2.3.4.5.6.7.8.9.10.txt
    文件名包含逗号 (,)
    你可以在文件名中使用逗号,可以有任意多个而不用特殊对待。就像平时普通名字文件那样处理。

    $ touch ,12.txt
    或者
    $ touch ,12,.txt
    文件名包含冒号 (:)
    用单引号括起来或使用反斜杠转义。(LCTT 译注:此处原文有误,已修改)

    $ touch ':12.txt'
    或者
    $ touch ':12:.txt'
    文件名包含引号(单引号和双引号)
    要在文件名里使用引号,我们需要使用交替规则。例如,如果你需要在文件名里使用单引号,那就用双引号把文件名括起来。而如果你需要在文件名里使用双引号,那就用单引号把文件名括起来。(LCTT 译注:或者如果单引号和双引号混杂的情况,你也可以用反斜杠转义。)

    $ touch "15'.txt"

    以及

    $ touch '15".txt'
    文件名包含波浪号 (~)
    Linux 下一些像 emacs 这样的文本编辑器在编辑文件的时候会创建备份文件。这个备份文件的名字是在原文件名后面附加一个波浪号。你可以在文件名任意位置使用波浪号,例如:

    $ touch ~1a.txt
    或者
    $touch 2b~.txt
    文件名包含空格
    创建名字的字符/单词之间包含空格的文件,比如 “hi my name is avishek.txt”。

    最好不要在文件名里使用空格,如果你必须要分隔可读的名字,可以使用下划线或横杠。不过,你还是需要创建这样的文件的话,你可以用反斜杠来转义下一个字符。要创建上面名字的文件可以这样做。

    $ touch hi my name is avishek.txt

    hi my name is avishek.txt
    我已经尝试覆盖你可能碰到的所有情况。上面大多数测试都在 BASH Shell 里完成,可能在其他 shell 下会有差异。

    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ ls
    Client.php  Exception.php  Function.Business.php  Interface.php  Mock  Mock.php  Model  Model.php  Samples  Samples - Copy  Show
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ ll
    total 112
    drwxr-xr-x 7 root root  4096 May  4 19:47 ./
    drwxr-xr-x 3 root root  4096 May  4 19:45 ../
    -rwxrwxrwx 1 root root 36520 Apr 10 12:03 Client.php*
    -rwxrwxrwx 1 root root  5033 Mar  2 12:41 Exception.php*
    -rwxrwxrwx 1 root root  3542 Apr 24 16:24 Function.Business.php*
    -rwxrwxrwx 1 root root  4708 Mar  2 12:41 Interface.php*
    drwxrwxrwx 2 root root  4096 May  4 19:47 Mock/
    -rwxrwxrwx 1 root root  6437 Mar  2 12:41 Mock.php*
    drwxrwxrwx 2 root root  4096 May  4 19:47 Model/
    -rwxrwxrwx 1 root root 17734 Mar  2 12:41 Model.php*
    drwxrwxrwx 2 root root  4096 May  4 19:47 Samples/
    drwxrwxrwx 3 root root  4096 May  4 15:30 Samples - Copy/
    drwxrwxrwx 2 root root  4096 Apr 10 09:51 Show/
    well@well:/home/etc/project/apilinux/MarketplaceWebServiceOrders$ 
    sudo apt-get install foremost

    w

    debugfs:  ?
    Available debugfs requests:
    
    show_debugfs_params, params
                             Show debugfs parameters
    open_filesys, open       Open a filesystem
    close_filesys, close     Close the filesystem
    freefrag, e2freefrag     Report free space fragmentation
    feature, features        Set/print superblock features
    dirty_filesys, dirty     Mark the filesystem as dirty
    init_filesys             Initialize a filesystem (DESTROYS DATA)
    show_super_stats, stats  Show superblock statistics
    ncheck                   Do inode->name translation
    icheck                   Do block->inode translation
    change_root_directory, chroot
                             Change root directory
    change_working_directory, cd
                             Change working directory
    list_directory, ls       List directory
    show_inode_info, stat    Show inode information 
    dump_extents, extents, ex
                             Dump extents information 
    blocks                   Dump blocks used by an inode 
    filefrag                 Report fragmentation information for an inode
    link, ln                 Create directory link
    unlink                   Delete a directory link
    mkdir                    Create a directory
    rmdir                    Remove a directory
    rm                       Remove a file (unlink and kill_file, if appropriate)
    kill_file                Deallocate an inode and its blocks
    clri                     Clear an inode's contents
    freei                    Clear an inode's in-use flag
    seti                     Set an inode's in-use flag
    testi                    Test an inode's in-use flag
    freeb                    Clear a block's in-use flag
    setb                     Set a block's in-use flag
    testb                    Test a block's in-use flag
    modify_inode, mi         Modify an inode by structure
    find_free_block, ffb     Find free block(s)
    find_free_inode, ffi     Find free inode(s)
    print_working_directory, pwd
                             Print current working directory
    expand_dir, expand       Expand directory
    mknod                    Create a special file
    list_deleted_inodes, lsdel
                             List deleted inodes
    undelete, undel          Undelete file
    write                    Copy a file from your native filesystem
    dump_inode, dump         Dump an inode out to a file
    cat                      Dump an inode out to stdout
    lcd                      Change the current directory on your native filesystem
    rdump                    Recursively dump a directory to the native filesystem
    set_super_value, ssv     Set superblock value
    set_inode_field, sif     Set inode field
    set_block_group, set_bg  Set block group descriptor field
    logdump                  Dump the contents of the journal
    htree_dump, htree        Dump a hash-indexed directory
    dx_hash, hash            Calculate the directory hash of a filename
    dirsearch                Search a directory for a particular filename
    bmap                     Calculate the logical->physical block mapping for an inode
    punch, truncate          Punch (or truncate) blocks from an inode by deallocating them
    symlink                  Create a symbolic link
    imap                     Calculate the location of an inode
    dump_unused              Dump unused blocks
    set_current_time         Set current time to use when setting filesystem fields
    supported_features       Print features supported by this version of e2fsprogs
    dump_mmp                 Dump MMP information
    set_mmp_value, smmp      Set MMP value
    extent_open, eo          Open inode for extent manipulation
    zap_block, zap           Zap block: fill with 0, pattern, flip bits etc.
    block_dump, bd           Dump contents of a block
    help                     Display info on command or topic.
    list_requests, lr, ?     List available commands.
    quit, q                  Leave the subsystem.
    debugfs:  
    debugfs:  
    debugfs:  
    debugfs:  
    debugfs:  q

    linux 删除文件和目录与恢复详解-linux-操作系统-壹聚教程网
    http://www.111cn.net/sys/linux/47629.htm

  • 相关阅读:
    【报错】引入jar包import org.apache.commons.codec.digest.DigestUtils 报错,jar不存在
    【spring data jpa】使用jpa的@Query,自己写的语句,报错:org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'status' cannot be found on null
    【java】在分页查询结果中对最后的结果集List进行操作add()或remove()操作,报错:java.lang.UnsupportedOperationException
    【java】java中直接根据Date 获取明天的时间
    【java】处理时间字段 在数据库查询的时候只想要年月日,不想要时分秒 ,java中设置时间类型为年月日,java中设置Date中的时分秒为00.00.000
    【spring data jpa】 spring data jpa 中 时间格式设置between and 查询
    【mybatis】mybatis 中select 查询 select * 查询出来的数据,字段值带不出来 数据不全
    【spring mvc】spring mvc POST方式接收单个字符串参数,不加注解,接收到的值为null,加上@RequestBody,接收到{"uid":"品牌分类大”},加上@RequestParam报错 ---- GET方式接收单个参数的方法
    Centos7安装配置tomcat 9并设置自动启动
    centos7 yum安装配置redis 并设置密码
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6808914.html
Copyright © 2011-2022 走看看